Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Writea program newCircle.cpp that can create one instance of the circle class wi

ID: 3720468 • Letter: W

Question

Writea program newCircle.cpp that can create one instance of the circle class with radius, centerX, and centerY, specified by the user.

// Example program
#include <iostream>
#include <string>

#ifndef CIRCLE_H
#define CIRCLE_H


using namespace std;

class Circle

{
//Circle declaration
class Circle
int main
{
     private:
     double radius, centerX, centerY;
   
     public:
     void setradius(double);
     void setCenter(double, double);
   
     double getRadius() const
     {return radius; }
   
     double getCenterX() const
     {return centerX; }
   
     doube getCenterY() const
     {return centerY; }
   
     double getArea() const
     {return 3.14* radius * radius; }
     };
     #endif
   
     return 0;

Explanation / Answer

Circle instance created by using driver method main()
Cpp code:
#include <iostream>
#include <string>
#define CIRCLE_H

using namespace std;
class Circle
{
private:
double radius, centerX, centerY;

public:
void setradius(double radius){
this->radius=radius;
}
void setCenter(double centerX, double centerY){
this->centerX=centerX;
this->centerY=centerY;
}

double getRadius() const
{return radius; }

double getCenterX() const
{return centerX; }

double getCenterY() const
{return centerY; }

double getArea() const
{return 3.14* radius * radius; }
};
int main()
{
Circle circle;
double radius,centerX,centerY;
cout << "Creation of Circle :" << endl;
cout << "Please the Enter the Radius of the Circle :" << endl;
cin >> radius;
cout << "Please Enter the CenterX of the Circle" << endl;
cin >> centerX;
cout << "Please Enter the CenterY of the Circle" << endl;
cin >> centerY;
circle.setradius(radius);
circle.setCenter(centerX,centerY);
cout << "Circle Instance Created !!" << endl;
cout << "Circle Area : " << circle.getArea() << endl;
cout << "Circle Radius : " << circle.getRadius() << endl;
cout << "Circle Centers(x,y) : (" << circle.getCenterX() << "," << circle.getCenterY() << ")" << endl;

return 0;
}