Advertisement
rootuss

switch

Nov 4th, 2016
246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.36 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdlib>
  3. #include <conio.h>
  4. #include <stdio.h>
  5.  
  6. using namespace std;
  7.  
  8. int main()
  9. {
  10.     float x, y;
  11.  
  12.     for(;;)
  13.     {
  14.  
  15.  
  16.     cout << "Podaj x i y" << endl;
  17.     cout<<"x= ";
  18.     cin>>x;
  19.     cout<<"y= ";
  20.     cin>>y;
  21.  
  22.  
  23.     cout<<"MENU GLOWNE"<<endl;
  24.     cout<<"************"<<endl;
  25.     cout<<"1. Dodawanie"<<endl;
  26.     cout<<"2. Odejmowanie"<<endl;
  27.     cout<<"3. Mnozenie"<<endl;
  28.     cout<<"4. Dzielenie"<<endl;
  29.     cout<<"4. Dzielenie"<<endl;
  30.     cout<<"5. Komiec"<<endl;
  31.     char wybor;
  32.     cout<<"Podaj numer dzialania: ";
  33.     wybor=getch();
  34.  
  35.    switch(wybor)
  36.     {
  37.     case '1':
  38.         {
  39.             cout<<"Suma to "<<x+y;
  40.  
  41.         break;
  42.         }
  43.     case '2':
  44.         {
  45.         cout<<"Roznica to to "<<x-y;
  46.         break;
  47.         }
  48.     case '3':
  49.         {
  50.         cout<<"Iloczyn to "<<x*y;
  51.         break;
  52.         }
  53.     case '4':
  54.         {
  55.             if(y==0)
  56.             {
  57.                 cout<<"Nie dzilimy przez 0"<<endl;
  58.             }
  59.             else
  60.             {
  61.                 cout<<"Iloraz to "<<x/y;
  62.             }
  63.  
  64.         break;
  65.         }
  66.  
  67.     case '5':
  68.         {
  69.            exit(0);
  70.        }
  71.     default:
  72.         {
  73.             cout<<"\n\n\ Brak opcji w MENU" <<endl;
  74.         }
  75.  
  76.  
  77.  
  78.  
  79.  
  80.     }
  81.     getchar();getchar();
  82.         system("cls");
  83.     }
  84.     return 0;
  85. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement