Advertisement
Guest User

Untitled

a guest
Feb 17th, 2020
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.68 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. class Geometrical_figure
  4. {
  5. private:
  6. double pi, r, a, b, h;
  7. public:
  8. double V_sphere , V_cylinder, V_rectangular_parallelepiped;
  9. void set_Pi(double buf1)
  10. {
  11. pi = buf1;
  12. }
  13. double get_Pi()
  14. {
  15. return pi;
  16. }
  17. void set_R(double buf2)
  18. {
  19. r = buf2;
  20. }
  21. double get_R()
  22. {
  23. return r;
  24. }
  25. void set_A(double buf3)
  26. {
  27. a = buf3;
  28. }
  29. double get_A()
  30. {
  31. return a;
  32. }
  33. void set_B(double buf4)
  34. {
  35. b = buf4;
  36. }
  37. double get_B()
  38. {
  39. return b;
  40. }
  41. void set_H(double buf5)
  42. {
  43. h = buf5;
  44. }
  45. double get_H()
  46. {
  47. return h;
  48. }
  49. double Volume_sphere()
  50. {
  51. V_sphere = (4 * pi * r * r * r) /3 ;
  52. return V_sphere;
  53. }
  54. double Volume_cylinder()
  55. {
  56. V_cylinder = pi * r * r * h;
  57. return V_cylinder;
  58. }
  59. double Volume_rectangular_parallelepiped()
  60. {
  61. V_rectangular_parallelepiped = a * b * h;
  62. return V_rectangular_parallelepiped;
  63. }
  64. };
  65. int main()
  66. {
  67. double buf1 , buf2, buf3, buf4, buf5, buf6, buf7;
  68. buf1 = 3.14;
  69. setlocale(LC_ALL, "Russian");
  70. cout << "Введите радиус " << endl;
  71. cin >> buf2;
  72. cout << "Введите длину и ширину " << endl;
  73. cin >> buf3 >> buf4;
  74. cout << " Введите высоту " << endl;
  75. cin >> buf5;
  76. Geometrical_figure examp;
  77. examp.set_Pi(buf1);
  78. examp.set_R(buf2);
  79. examp.set_A(buf3);
  80. examp.set_B(buf4);
  81. examp.set_H(buf5);
  82. cout << " Объем сферы равен " << examp.Volume_sphere() << endl;
  83. cout << " Объем цилиндра равен " << examp.Volume_cylinder() << endl;
  84. cout << "Объем прямого параллелепипеда равен " << examp.Volume_rectangular_parallelepiped() << endl;
  85. return 0;
  86. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement