Write a program to create a base class named “circle”. Derive another class “cylinder” from it. The program should calcu

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

Write a program to create a base class named “circle”. Derive another class “cylinder” from it. The program should calcu

Post by answerhappygod »

Write a program to create a base class named “circle”. Derive
another class “cylinder” from it. The program should calculate
total surface area of circle and cylinder using the concept of
inheritance. Circle should have data fields i.e. radius, area and
method getRadius ( ) should take value of radius from user.
Cylinder should have additional data field i.e. height and
additional method getHeight ( ) to assign value of height.
Similarly, area ( ) function calculates area and display ( )
function prints the final area of the created objects i.e circle
and cylinder. (Circle surface area=pi*r*r and cylinder surface
area=2*pi*r*r+2*r*h)
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply