Advertisement
programusy

Untitled

Jan 8th, 2024
15
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.57 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. class figura
  6. {
  7. public:
  8. string nazwa;
  9. int ilosc_bokow;
  10.  
  11. };
  12.  
  13. class trojkat : public figura
  14. {
  15. private:
  16. double a;
  17. double b;
  18. double c;
  19. double wys;
  20.  
  21. public:
  22. void podaj_boki();
  23. void podaj_wys();
  24. void wyswietl_boki();
  25. double pole();
  26. double obwod();
  27. double suma_katow();
  28.  
  29. trojkat();
  30.  
  31. };
  32.  
  33. trojkat::trojkat()
  34. {
  35. ilosc_bokow = 3;
  36. }
  37.  
  38. void trojkat::podaj_boki()
  39. {
  40. cout << "Podaj a: " << endl;
  41. cin >> a;
  42. cout << "Podaj b: " << endl;
  43. cin >> b;
  44. cout << "Podaj c: " << endl;
  45. cin >> c;
  46. }
  47.  
  48. void trojkat::podaj_wys()
  49. {
  50. cout << "Podaj wysokosc" << endl;
  51. cin >> wys;
  52. }
  53.  
  54. void trojkat::wyswietl_boki()
  55. {
  56. cout << "a = " << a << endl;
  57. cout << "b = " << b << endl;
  58. cout << "c = " << c << endl;
  59. }
  60.  
  61. double trojkat::pole()
  62. {
  63. return (a * wys) / 2;
  64. }
  65.  
  66. double trojkat::obwod()
  67. {
  68. return a + b + c;
  69. }
  70.  
  71. double trojkat::suma_katow()
  72. {
  73. return (ilosc_bokow - 2) * 180;
  74. }
  75.  
  76. int main()
  77. {
  78. figura f;
  79. trojkat t1;
  80. trojkat t2;
  81. trojkat t3;
  82. trojkat t4;
  83.  
  84. f.nazwa = "Figura";
  85. cout << f.nazwa << endl;
  86. cout << endl;
  87.  
  88. t1.nazwa = "Trojkat typu duzy";
  89. t1.podaj_boki();
  90. t1.wyswietl_boki();
  91. t1.podaj_wys();
  92. cout << "Pole wynosi: " << t1.pole() << endl;
  93. cout << "Obwod wynosi: " << t1.obwod() << endl;
  94. cout << "Suma katow wynosi: " << t1.suma_katow() << endl;
  95.  
  96. return 0;
  97. }
  98.  
  99.  
  100.  
  101.  
  102.  
  103.  
  104.  
  105.  
  106.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement