Question: Question Two ( 1 5 marks ) Design a Java class named Circle that contains: Data field: private double radius Methods A constructor that creates

Question Two (15 marks)
Design a Java class named Circle that contains:
Data field:
private double radius
Methods
A constructor that creates circle with the specified radius
Methods to set and get radius
A method named calculatePerimeter that calculates the perimeter of the circle.
A method
named calculateArea that calculates the area of the circle.
Create a subclass "Cylinder" of "Circle" as follows:
Cylinder has a private double height data field. A constructor that creates cylinder with the specified height. A method named calculateVolume that calculate the volume of the cylinder.
Override the calculateArea method in the circle class to calculate the surface area of the cylinder.
Write a test program that creates a Circle and Cylinder and invoke their methods.
Formula: Perimeter of circle =2r
Volume of cylinder =r2h
Question Two ( 1 5 marks ) Design a Java class

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 Programming Questions!