#include <iostream>
#include <stdio.h>
#include <cstdlib>
#include <conio.h>
using namespace std;
float x, y;
char wybor;
int main()
{
for (;;) {
cout << "Liczba 1: ";
cin >> x;
cout << "Liczba 2: ";
cin >> y;
cout << endl;
cout << " MENU" << endl;
cout << "-------------" << endl;
cout << "1. Dodawanie" << endl;
cout << "2. Odejmowanie" << endl;
cout << "3. Mnozenie" << endl;
cout << "4. Dzielenie" << endl;
cout << "5. Wyjdz" << endl;
cout << "-------------";
cout << endl
<< ": ";
wybor = getchar();
cout << endl;
switch (wybor) {
case '1':
cout << "Wynik: " << x + y << endl
<< endl;
break;
case '2':
cout << "Wynik: " << x - y << endl
<< endl;
break;
case '3':
cout << "Wynik: " << x * y << endl
<< endl;
break;
case '4':
if (y == 0)
cout << "Pamietaj cholero nie dziel przez zero -_-" << endl
<< endl;
else
cout << "Wynik: " << x / y << endl
<< endl;
break;
case '5':
exit(0);
break;
default:
cout << "Nie ma takiej opcji!" << endl
<< endl;
}
getchar();
getchar();
system("cls");
}
return 0;
}
I don't know why the program is not waiting for me to click any button, and automaticcly uses the default case, why is this happening, what I am doing wrong, just how to fix it :O ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀