Question: Write a class called Circle that has the following member variable: radius : a double value to hold radius of the circle. PI : a

Write a class called Circle that has the following member variable:
radius : a double value to hold radius of the circle.
PI : a static double value to hold value of PI with an initial value of 3.14159 to be
set in the constructor. This mean that PI will be duplicated in all Circle
objects which is not good. Later, we will improve on this later.
In addition, the class should have the following constructor and member functions
Constructor : Only one constructor with default value of 1 for radius
and 3.1459 for PI
Accessor (Getter) : to get value for radius. Should be a const
method.
Mutator (Setter) : to set value of radius.
getArea : method to return area of circle. PI*radius*radius
getDiameter : method to return diameter of circle. radius*2
getCircumference : get circumference of circle. 2*PI*radius
print() : method to print the circles radius, diameter, circumference
and area. This should be const method.
Demonstrate that your class is working by doing the following:
creating two different Circle objects : one with default values and one with
a given value of radius. You should prompt user to enter this value from
keyboard.
Call print method on both objects to report back the radius, diameter,
circumference and area. Clearly print heading (in main program) that
information follow is for which object?
Your Circle class declaration should be in its own Circle.h file.
Implementation of the Circle class should be in another file called Circle.cpp
Then lastly, your main() function should be in a different file.

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