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

I need to create a Circle.h file EXPECTED OUTPUT: Center: (0, 0) Radius: 1 Area:

ID: 3733538 • Letter: I

Question

I need to create a Circle.h file

EXPECTED OUTPUT:

Center:   (0, 0)
Radius:   1
Area:   3.14159

Center:   (1, 2)
Radius:   3

Create a C++ class named Circle, which you should store in a file called Circle.h. Your class should have three private variables, namely x, y, and r, all of type double. The variables x and y will store the Cartesian position of the center of the circle and the variable r should store the radius. You should also add a public variable, area,which will store the area of the cirde. Ther should be two constructors, one that takes no arguments and instantiates a uunit circle centered at the origin. The second constructor should take in three arguments, namely x, y and r, and instantiate a circle of radius r, centered at (x, y).

Explanation / Answer


class Circle{

private:
   double x, y, r;
public:
   double area;
   Circle(){
       x= 0;
       y=0;
       r = 1;
   }

   Circle(double x1, double y1, double r1) {
       x = x1;
       y = y1;
       r = r1;
   }

   double getX() {
       return x;
   }

   double getY() {
       return y;
   }

   double getR() {
       return r;
   }

   void setX(double x1) {
       x = x1;
   }

   void setY(double y1) {
       y = y1;
   }

   void setR(double r1) {
       r = r1;
   }
};

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote