SilverhandX

circlemain.cpp

May 2nd, 2016
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.57 KB | None | 0 0
  1. #include<iostream>
  2. #include"circle.h"
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     double input; //Variable for user input
  8.     double diffRad, diffArea, diffCirc; //Variables for calculating difference between 2 circles
  9.  
  10.     cout << "Please input a value for the radius of Circle 2: ";
  11.     cin >> input;
  12.     cout << endl;
  13.  
  14.     Circle c1;
  15.     Circle c2(input);
  16.  
  17.     cout << "Circle 1:\nRadius: " << c1.getRadius() << "\nArea: " << c1.getArea() << "\nCircumference: " << c1.getCircumference() << "\n\n";
  18.  
  19.     cout << "Circle 2:\nRadius: " << c2.getRadius() << "\nArea: " << c2.getArea() << "\nCircumference: " << c2.getCircumference() << "\n\n";
  20.  
  21.     cout << "Please input a new value for the radius of Circle 1: ";
  22.     cin >> input;
  23.     cout << endl;
  24.  
  25.     c1.setRadius(input);
  26.  
  27.     cout << "Circle 1:\nRadius: " << c1.getRadius() << "\nArea: " << c1.getArea() << "\nCircumference: " << c1.getCircumference() << "\n\n";
  28.  
  29.     cout << "Circle 2:\nRadius: " << c2.getRadius() << "\nArea: " << c2.getArea() << "\nCircumference: " << c2.getCircumference() << "\n\n";
  30.  
  31.     diffRad = c1.getRadius() - c2.getRadius();
  32.    
  33.     if(diffRad < 0) //If the difference is negative, changes it to positive for cleaner output, repeated for all 3 difference values
  34.     { diffRad = diffRad * -1; }
  35.  
  36.     diffArea = c1.getArea() - c2.getArea();
  37.  
  38.     if(diffArea < 0)
  39.     { diffArea = diffArea * -1; }
  40.  
  41.     diffCirc = c1.getCircumference() - c2.getCircumference();
  42.  
  43.     if (diffCirc < 0)
  44.     { diffCirc = diffCirc * -1; }
  45.  
  46.     cout << "Difference in Circles:\nRadius: " << diffRad << "\nArea: " << diffArea << "\nCircumference: " << diffCirc << "\n\n";
  47.  
  48.     return 0;
  49. }
Add Comment
Please, Sign In to add comment