Implement a circle class in C++ each object of this will represent a circle storing its radius and X&Y coordinates of the centers as floats include a default constructor access function and area and circumference of the circle.
#include <iostream.h>
#include <conio.h>
#include <math.h>
class Circle {
private:
float radius;
float x;
float y;
public:
Circle() { // Default constructor
radius = 0;
x = 0;
y = 0;
}
Circle(float r, float xCoord, float yCoord) { // Constructor with parameters
radius = r;
x = xCoord;
y = yCoord;
}
float getRadius() {
return radius;
}
float getX() {
return x;
}
float getY() {
return y;
}
float area() {
return M_PI * radius * radius;
}
float circumference() {
return 2 * M_PI * radius;
}
};
void main() {
float radius, xCoord, yCoord;
cout << "Enter the radius of the circle: ";
cin >> radius;
cout << "Enter the X coordinate of the center of the circle: ";
cin >> xCoord;
cout << "Enter the Y coordinate of the center of the circle: ";
cin >> yCoord;
Circle c(radius, xCoord, yCoord); // Create a Circle object with the input values
cout << "Radius: " << c.getRadius() << endl;
cout << "X coordinate: " << c.getX() << endl;
cout << "Y coordinate: " << c.getY() << endl;
cout << "Area: " << c.area() << endl;
cout << "Circumference: " << c.circumference() << endl;
getch();
}