Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- using namespace std;
- class ring{
- public:
- void read(){
- cout << "x: ";
- cin >> x;
- cout << "y: ";
- cin >> y;
- cout << "R1: ";
- cin >> radius1;
- cout << "R2: ";
- cin >> radius2;
- }
- double getArea() const {
- return M_PI * (radius2 * radius2 - radius1 * radius1);
- }
- void printRing() const {
- cout << "Coordinates: (" << x << "; " << y << ")" << endl;
- cout << "R1: " << radius1 << endl;
- cout << "R2: " << radius2 << endl;
- cout << "Area:" << getArea() << endl;
- }
- void toCircle(){
- radius1 = 0;
- }
- private:
- double x, y, radius1, radius2;
- };
- int main(){
- ring ring1;
- ring1.read();
- ring1.toCircle();
- ring1.printRing();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement