Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include"circle.h"
- using namespace std;
- int main()
- {
- double input; //Variable for user input
- double diffRad, diffArea, diffCirc; //Variables for calculating difference between 2 circles
- cout << "Please input a value for the radius of Circle 2: ";
- cin >> input;
- cout << endl;
- Circle c1;
- Circle c2(input);
- cout << "Circle 1:\nRadius: " << c1.getRadius() << "\nArea: " << c1.getArea() << "\nCircumference: " << c1.getCircumference() << "\n\n";
- cout << "Circle 2:\nRadius: " << c2.getRadius() << "\nArea: " << c2.getArea() << "\nCircumference: " << c2.getCircumference() << "\n\n";
- cout << "Please input a new value for the radius of Circle 1: ";
- cin >> input;
- cout << endl;
- c1.setRadius(input);
- cout << "Circle 1:\nRadius: " << c1.getRadius() << "\nArea: " << c1.getArea() << "\nCircumference: " << c1.getCircumference() << "\n\n";
- cout << "Circle 2:\nRadius: " << c2.getRadius() << "\nArea: " << c2.getArea() << "\nCircumference: " << c2.getCircumference() << "\n\n";
- diffRad = c1.getRadius() - c2.getRadius();
- if(diffRad < 0) //If the difference is negative, changes it to positive for cleaner output, repeated for all 3 difference values
- { diffRad = diffRad * -1; }
- diffArea = c1.getArea() - c2.getArea();
- if(diffArea < 0)
- { diffArea = diffArea * -1; }
- diffCirc = c1.getCircumference() - c2.getCircumference();
- if (diffCirc < 0)
- { diffCirc = diffCirc * -1; }
- cout << "Difference in Circles:\nRadius: " << diffRad << "\nArea: " << diffArea << "\nCircumference: " << diffCirc << "\n\n";
- return 0;
- }
Add Comment
Please, Sign In to add comment