<p>Write a Circle class that has the following data members:<br /><br />1. radiu
ID: 3634642 • Letter: #
Question
<p>Write a Circle class that has the following data members:<br /><br />1. radius: a double <br />2. pi: a double initialized with the value 3.1416 <br />3. The class should have the following member functions:<br /><br />-Default constructor: a default constructor that sets radius to 0.0. <br />-Constructor. Accepts the radius of the circle as an argument <br />-setRadius (int). A mutator function for the radius variable. <br />-int getRadius. An accessor function for the radius variable. <br />-inputRadius - from the keyboard <br />-displayCircle - In this object function you need to call the function getArea to calculate the area of a circle, -then display the radius of a circle and its area - format: Radius: ______, Area= ______ . <br />-getArea. Return the area of the circle, which is calculated as area = pi * radius * radius <br />-getDiameter. Return the diameter of the circle, which is calculated as diameter = radius *2 <br />-getCircumference. Return the circumference of the circle, which is calculated as circumference = 2 * pi *     radius. <br />-Write a program the demonstrate the Circle class perform the following tasks:<br /><br />1. Create a Circle object called C1 with radius equal to zero. <br />2. Create a Circle object called C2 with radius equal to 5.0 <br />3. Input the radius for the circle C1. Enter a value of 3.0 for the radius of the Circle C1. <br />4. Display the area of the circle C2 by calling the function getArea. <br />5. Display the diameter of the circle C2 by calling the function getDiameter. <br />6. Display the radius and area of the circle C1 by calling the function displayCircle. <br />7. Change the radius of the circle C1 to 10.0. <br />8. Display the circumference of the circle C1 by calling the function getCircumference..</p>Explanation / Answer
#include using namespace std; class Circle { private: double pi; double radius; public: Circle() { pi = 3.14159; radius =0.0; } Circle(double radius) { pi = 3.14159; this->radius = radius; } void setRadius(doubleradius) { this->radius = radius; } double getRadius() { returnradius; } double getArea() { return pi* radius * radius; } double getDiameter() { returnradius * 2; } double getCircumfrence() { return 2 *pi * radius; } }; int main() { /* Data object and variable. */ Circle circle = Circle(); double radius; /* Introductory message. */ coutRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.