Write a program that demonstrates the Right Circular Cone class by asking the user for the radius, and height then reporting the Right Circular Cone's volume and surface area. see image.

Formula:

(Surface area) a = PI * r * (r + sqrt(h^2+r^2))
Volume v = PI * r^2 * h/3

SPECIFICATIONS: (save it under Cone.h file)

Write a Cone class that has the following member variables.

radius - type double
height – type double
pi - type double

The class should have the following public member functions.

Cone - a default constructor
setRadius - Accepts an (type double) argument that is copied to radius
setHeight - Accepts an (type double) argument that is copied to height
getRadius - returns the value in radius
getHeight - returns the value in height
getSurfaceArea - returns the surface area of the Cube
getVolume - returns the volume of the cube

IMPLEMENTATION: (save it under Cone.cpp file)

It includes member functions:

Cone() - Default constructor that sets radius to 0.0, height to 0.0 and pi to 3.14159
setRadius - function that sets the radius
setHeight - function that sets the height
getRadius - function that returns the radius
getHeight - function that returns the height
getSurfaceArea - function that returns the surface area of the right circular cube
getArea - function that returns the area of the right circular cube

Save the driver program in the file Driver.cpp.

The driver program will start as:

double radius; // radius of cube
double height; // height of cube

Cube c; // Object c

// Get the radius from user
cout << "Enter the Cube's radius: ";
cin >> radius;
cout << "Enter the Cube's height: ";
cin >> height;

The Input screen:

Enter the Cube's radius: 10
Enter the Cube's height: 20.5

Sample output: (Numbers to be rounded to two digits after decimal point)

Surface Area of the Cube: 1030.72
Volume of the Cube : 2146.75
Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.