Question: Can someone help me with this, it needs to be done in C++. Can you also add comments in the code if possible so I
Can someone help me with this, it needs to be done in C++. Can you also add comments in the code if possible so I can see what is going on. I have attached screenshots, thank you!




I. Edit, compile, and run the following program on the UH UNIX shell: A. Develop a Shape class hierarchy and define the following classes in the hierarchy: Shape, Circle, Sphere, Cylinder, Square, Cube, Triangle, and Tetrahedron. B. From the abstract Shape class, derive concrete classes Circle, Square, and Triangle. From class Circle, derive concrete classes Sphere and Cylinder. From class Square, derive concrete class Cube. And from class Triangle, derive class Tetrahedron. C. Use the following functions a. virtual char* name0 const - returns the name of the class b. virtual void printSize) const display the area, or surface area & volume of the object c. virtual void inputData) - ask the user for the radius, side, and/or height of the object and set the appropriate data member(s) d. virtual double area const returns the area or surface area of the object e. virtual double volume) const returns the volume of the object D. The assignment24.cpp file contains class Shape - an abstract base class containing the interface to the hierarchy (Note: DO NOT change the Shape class definition), a class definition for the class Circle, the main) function, and example output. E. You should change the mainO function when you first start testing your program. For example, you should create the class Circle first, and test all the functions to make sure that it is working correctly. After you've finished the program, you should put in the original main() function. In other words, turn in your program with the same main) function as the main0) function that is already in the assignment24.cpp file F. For those rusty in geometry, here are some formulas PI = 3.14 circle's area PI*radius* radius sphere's surface area = 4*PI* radius* radius sphere's volume- 4/3*PI*radius* radius* radius cylinder's surface area = 2*(circle's area) + h*(circle's circumference) cylinder's volume = h*(circle's area) circle's circumference- 2*PI radius square's area = s*s cube's surface area= 6"(square's area) cube's volume s*s*s equilateral triangle's area-s*s*sqrt(3)/4 regular tetrahedron's surface area 4*(equilateral triangle's area) regular tetrahedron's volume sss sqrt(2)/12 G. ** NOTE: The main error students make with this assignment is to repeat data unnecessarily. The point of inheritance is to be a lazy programmer and not reinvent the wheel. For example, if the base class Circle has a radius, the derived class Sphere does NOT need a radius, because it already has a radius, which is inherited
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
