Question: solve using java Implement the following inheritance hierarchy: - Class ThreeDimRoundShape is the superclass of the hierarchy. It has one instance variable: radius (of type

solve using java solve using java Implement the following inheritance hierarchy: - Class ThreeDimRoundShape is

Implement the following inheritance hierarchy: - Class ThreeDimRoundShape is the superclass of the hierarchy. It has one instance variable: radius (of type double). It has a constructor that initializes the radius to the specified value. It has two methods: toString that returns the string representation of the radius, getRadius that returns the value of the radius. - Class Cylinder is derived from ThreeDimRoundShape. It has one instance variable: height (of type double). It has a constructor that calls the superclass constructor to initialize the radius to the specified value and then it initializes height to the specified value. It has three methods: a method getArea that returns the surface area of the cylinder (Surface Area =2rh, where r is the radius and h is the height), a method getVolume that returns the volume of the cylinder (Volume =r2h. where r is the radius and h is the height), and a method tostring that overrides the superclass version and retums the string representation of the radius, height, area and volume. - Class Sphere is derived from ThreeDimRoundShape. It has a constructor that calls the superclass constructor to initialize the radius to the specifled value. It has three methods: a method getArea that returns the surface area of the sphere (Surface Area = 4r2, where r is the radius), a method getVolume that returns the volume of the sphere (Volume =34r3, where r is the radius), and a method toString that overrides the superclass version and retums the string representation of the radius, area and volume. - Write a test class named ThreeDimRoundShapeTest that has a main method to test your classes. In the main method, prompt the user to input the information of both shapes. Create ThreeDimRoundShape, Cylinder and Sphere objects and initialize the objects with the values entered by the user. Call toString method for each object and print the output. Sample Output: Enter the 30 round shape: $ Enter the radius of the aphere: 2 Enter the radius of the cylinder: 3 Enter the height of the cylinder: 6 The 3 D round shape: Radiua =5.00 The Sphere: Radiua -2.00 Area =50.27 Volume =33.51 The Cylinder: Radius -3.00 Beight -6.00 Area -113.10 Volume -169.65

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!