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

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

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

Post 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πœ‹π‘Ÿ ).
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply