Write a program that instantiates four sphere objects (assigning a radius to each instance) and adds them to a pointer-based linked list. Include a function to display the statistics of each sphere in the list.
// ***************************************************
// Header file for the class sphereClass.
// ***************************************************
const double PI = 3.14159;
class sphereClass
{
public:
sphereClass();
// Default constructor: Creates a sphere and
// initializes its radius to a default value.
// Precondition: None.
// Postcondition: A sphere of radius 1 exists.
sphereClass(double InitialRadius);
// Constructor: Creates a sphere and initializes
// its radius.
// Precondition: InitialRadius is the desired
// radius.
// Postcondition: A sphere of radius InitialRadius
// exists.
void SetRadius(double NewRadius);
// Sets (alters) the radius of an existing sphere.
// Precondition: NewRadius is the desired radius.
// Postcondition: The sphere's radius is NewRadius.
double Radius() const;
// Determines a sphere's radius.
// Precondition: None.
// Postcondition: Returns the radius.
double Diameter() const;
// Determines a sphere's diameter.
// Precondition: None.
// Postcondition: Returns the diameter.
double Circumference() const;
// Determines a sphere's circumference.
// Precondition: PI is a named constant.
// Postcondition: Returns the circumference.
double Area() const;
// Determines a sphere's surface area.
// Precondition: PI is a named constant.
// Postcondition: Returns the surface area.
double Volume() const;
// Determines a sphere's volume.
// Precondition: PI is a named constant.
// Postcondition: Returns the volume.
void DisplayStatistics() const;
// Displays statistics of a sphere.
// Precondition: None.
// Postcondition: Displays the radius, diameter,
// circumference, area, and volume.
private:
double TheRadius; // the sphere's radius
}; // end class
// End of header file.