Starting from:
$35

$29

Programming Assignment 5 Solution

Write a Cylinder class that extends your Circle class.




Requirements




If your code does not compile, you will receive an automatic score of 0. It is YOUR responsibility to come see ME for help if you need it.
(1 point) The source code file and class must be named Cylinder.java.



(1 point) You should have a Javadoc comment at the top of your class with the purpose of the class and your name.
(1 point) The class should have a height field that is of type double and only visible to an object.



(2 points) Add a constructor that allows an object to be created with a double value for the height and radius fields. If a parameter value is negative, set the field to zero instead.



(2 points) Add a constructor that allows an object to be created with a String value for the height and radius fields. If a parameter value is negative, set the field to zero instead.



(2 points) Add a copy constructor to the class.



(1 point) The class should have an accessor method named getHeight.



(2 points) The class should have a method named getVolume that returns the value of the



volume of a Cylinder object. Use Math.PI for pi.




10) (2 points) The class should have a method named getSurfaceArea that returns the value of the surface area of a Cylinder object. Use Math.PI for pi.




11) (2 points) Add an equals method to the class.




12) (2 points) Add a copy method to the class.




13) (2 points) Add a toString method that produces,




Cylinder:




height: ##




Circle radius: ##




where ## is replaced with the current value of the height/radius for the Cylinder object.




14) (4 points) You should have proper Javadoc comments directly above all methods with a description of the method and any necessary tags and descriptions.




15) (1 point) Use good programming practices throughout the code (variable names are descriptive and follow variable naming conventions, properly indent different parts of the code, vertically line up curly braces or headers, lines of code are not longer than 80 characters, etc.).







Submit the source file in Blackboard




Log into Blackboard and go to our course page. Under Content in the left menu, open the folder for the Programming Assignments. Click on the link for Program 5. Under Assignment Submission, use Browse My Computer next to Attach File and find the .java file. Only submit the .java file! When the file has been attached, click the Submit button.

More products