Kacper_Michalak

Zadanie switch 4

Nov 24th, 2020 (edited)
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.12 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. int main()
  4. {
  5.     char x;
  6.     int a, b;
  7.     int pole = 0;
  8.     cout << "Podaj litere a,b,c lub d" << endl;
  9.     cin >> x;
  10.  
  11.     switch (x)
  12.     {
  13.     case 'a':
  14.         cout << "Podaj dlugosc pierwszego boku" << endl;
  15.         cin >> a;
  16.         cout << "Podaj dlugosc drugiego boku" << endl;
  17.         cin >> b;
  18.         pole = a * b;
  19.         cout << "Pole prostokata wynosi : " << pole << endl;
  20.         break;
  21.     case 'b':
  22.         cout << "Podaj dlugosc boku" << endl;
  23.         cin >> a;
  24.         pole = a * a;
  25.         cout << "Pole kwadratu wynosi : " << pole << endl;
  26.         break;
  27.     case 'c':
  28.         cout << "Podaj dlugosc podstawy" << endl;
  29.         cin >> a;
  30.         cout << "Podaj dlugosc wysokosci" << endl;
  31.         cin >> b;
  32.         pole = 0.5 * a * b;
  33.         cout << "Pole trojkata wynosi : " << pole << endl;
  34.         break;
  35.     case 'd':
  36.         cout << "Podaj dlugosc promienia kola" << endl;
  37.         cin >> a;
  38.         pole = 3.14 * (a* a);
  39.         cout << "Pole kola wynosi: " << pole << endl;
  40.     default:
  41.         cout << "Podano zla litere" << endl;
  42.     }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment