Question: 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

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

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