Page 1 of 1

Create a Circle class with 2 attributes (radius(decimal), pi(decimal)). Create a constructor with 1 parameter for radius

Posted: Fri May 20, 2022 12:02 pm
by answerhappygod
Create a Circle class with 2 attributes (radius(decimal), pi(decimal)). Create a constructor with 1 parameter for radius. Pi has a default value – 3.14. Create accessor methods for these attributes. Create an area() method that returns the area of the circle. ( 𝐴 = 𝜋𝑟2) Create a Cylinder class that extends Circle class and add 1 more attribute (height). Create accessor method for this attribute and a constructor with 2 parameters that calls the constructor from the superclass. Create a volume() method that returns the volume of the cylinder by using the method area() from the superclass. (𝑉 = h𝜋𝑟2) Override the area() method to calculate the area of the entire surface of the cylinder. (𝑆 = 2𝜋𝑟2 + 2h𝜋𝑟 ).