Advertisement
Cyzol

Kalkulator pyśki

Mar 23rd, 2019
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.88 KB | None | 0 0
  1. #include "pch.h"
  2. #include <iostream>
  3. #include <string>
  4.  
  5. //Kalkulator
  6.  
  7. using namespace std;
  8.  
  9. int main()
  10. {
  11.     int a, b;
  12.     char znak;
  13.     string decyzja;
  14.  
  15.     do
  16.     {
  17.         cout << "Podaj pierwsza liczbe" << endl;
  18.         cin >> a;
  19.         cout << " Podaj znak działania" << endl;
  20.         cin >> znak;
  21.         cout << "Podaj druga liczbe" << endl;
  22.         cin >> b;
  23.  
  24.  
  25.         switch (znak)
  26.         {
  27.         case'+': cout << "Oto wynik dodawania : " << a + b << endl;
  28.             break;
  29.         case'-': cout << "Oto wynik odejmowania : " << a - b << endl;
  30.             break;
  31.         case'*': cout << "Oto wynik mnozenia : " << a * b << endl;
  32.             break;
  33.         case'/': cout << "Oto wynik dzielenia : " << a / b << endl;
  34.             break;
  35.         default: cout << "Nie ma takiego dzialania, upewnij sie czy wszystko dobrze wpisales.";
  36.         }
  37.  
  38.         cout << "Czy chcesz jeszcze raz dokonac dzialania? " << endl;
  39.         cin >> decyzja;
  40.     }
  41.  
  42.     while (decyzja == "tak");
  43.  
  44.     return 0;
  45.        
  46.  
  47.  
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement