Advertisement
Guest User

homework2

a guest
Feb 19th, 2020
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.03 KB | None | 0 0
  1. #include <string>
  2. #include <vector>
  3. #include <iostream>
  4. #include <algorithm>
  5.  
  6. using namespace std;
  7.  
  8.  
  9. class Quadrate
  10. {
  11.  
  12. private:
  13.     double Side1 = 0, Side2 = 0, radius = 0, hight = 0, square1 = 0;
  14.  
  15. public:
  16.  
  17.     void quadratesquare(double _quadrate_side)
  18.     {
  19.         Side1 = max(_quadrate_side, 0.0);
  20.     }
  21.  
  22.     void rectanglesquare(double _rectangle_upside, double _rectangle_leftside)
  23.     {
  24.         Side1 = max(_rectangle_upside, 0.0);
  25.         Side2 = max(_rectangle_leftside, 0.0);
  26.     }
  27.  
  28.     void cylindersquare(double _cylinder_circle, double _cylinder_h)
  29.     {
  30.         Side1 = max(_cylinder_circle, 0.0);
  31.         hight = max(_cylinder_h, 0.0);
  32.     }
  33.  
  34.  
  35.     double Square()
  36.     {
  37.         if (Side2 == 0)
  38.         {
  39.             square1 = Side1 * Side1;
  40.         }
  41.         if (Side1 > 0 && Side2 > 0 && hight == 0)
  42.         {
  43.             square1 = Side1 * Side2;
  44.         }
  45.         if (Side1 > 0 && hight > 0)
  46.         {
  47.             square1 = 3.14 * Side1 * Side1 * hight;
  48.         }
  49.         return square1;
  50.     }
  51. };
  52.  
  53.  
  54.  
  55. int main()
  56. {
  57.     setlocale(LC_CTYPE, "russian");
  58.     double quadrate_side = 0, rectangle_leftside = 0, rectangle_upside = 0, cylinder_circle = 0, cylinder_h = 0;
  59.     Quadrate ashotakoe;
  60.     cout << "Введите величину стороны квадрата: " << endl;
  61.     cin >> quadrate_side;
  62.     cout << endl;
  63.     cout << "Введите величину первой и второй стороны прямоугольника: " << endl;
  64.     cin >> rectangle_leftside;
  65.     cin >> rectangle_upside;
  66.     cout << endl;
  67.     cout << "Введите величину радиуса основания цилиндра и его высоту: " << endl;
  68.     cin >> cylinder_circle;
  69.     cin >> cylinder_h;
  70.     cout << endl;
  71.     ashotakoe.quadratesquare(quadrate_side);
  72.     cout << "Площадь квадрата равна: " << ashotakoe.Square() << endl;
  73.     ashotakoe.rectanglesquare(rectangle_leftside, rectangle_upside);
  74.     cout << "Площадь прямоугольника равна: " << ashotakoe.Square() << endl;
  75.     ashotakoe.cylindersquare(cylinder_circle, cylinder_h);
  76.     cout << "Объем цилиндра равен: " << ashotakoe.Square() << endl;
  77.     system("pause");
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement