Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Q1- Write a C++ program that has following class diagram: Shape +printArea(): virtual void +printCircumference(): virtual void Triangle Circle Rectangle -base: int -radius: int -breadth:
Q1- Write a C++ program that has following class diagram: Shape +printArea(): virtual void +printCircumference(): virtual void Triangle Circle Rectangle -base: int -radius: int -breadth: int -height: int +printArea():void +printCircumference():void -hypo: int -length: int +printArea():void +printCircumference():void +printArea():void +printCircumference():void You should implement setters and getters for all the variables of each class as well as defined variables and functions above. Shape class is the abstract parent class and triangle, circle and rectangle classes are inherited from the parent class. It is required Program needs to find the area and circumferences of shapes. Also, you need to create a method: int CalculateTotalArea (Shape **shapes). This method needs to calculate total area of each shapes created. Thanks to usage of polymorphism and abstract class, you may send any object from the child class of Shape class as a parameter to the function. Sample Output: ------ Enter how many rectangles you want to create: 2 Enter how many circles you want to create: 1 Enter how many triangles you want to create: 2 ---Rectangles-- Enter breadth and length respectively: 36 Enter breadth and length respectively: 4 5 Total Area of Rectangles: 38.0 ------ Triangles--- Enter base and height and hypo respectively: 6 8 10 Enter base and height and hypo respectively: 7 24 25 Total Area of Triangles: 216.0 ------Circles-- Enter radius: 4 Total Area of Circles: 50.24
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started