double a, b, res;
int answer;
cout << "Welcome. Calc v1" << endl;
cout << "1 - (+)" << endl;
cout << "2 - (-)" << endl;
cout << "3 - (*)" << endl;
cout << "4 - (/)" << endl;
cout << "0 - (exit)" << endl;
cin >> answer;
switch (answer)
{
case 0:
system("pause");
int answer;
cout << "Welcome. Calc v1" << endl;
cout << "1 - (+)" << endl;
cout << "2 - (-)" << endl;
cout << "3 - (*)" << endl;
cout << "4 - (/)" << endl;
cout << "0 - (exit)" << endl;
cin >> answer;
switch (answer)
{
case 0:
exit(0);case 1:
break;
cout << "Enter first number" << endl;case 2:
cin >> a;
cout << "Enter second number" << endl;
cin >> b;
res = a + b;
cout << "Summ = " << res << endl;
break;
cout << "Enter first number" << endl;case 3:
cin >> a;
cout << "Enter second number" << endl;
cin >> b;
res = a - b;
cout << "Sub = " << res << endl;
break;
cout << "Enter first number" << endl;case 4:
cin >> a;
cout << "Enter second number" << endl;
cin >> b;
res = a * b;
cout << "Mult = " << res << endl;
break;
cout << "Enter first number" << endl;default:
cin >> a;
cout << "Enter second number" << endl;
cin >> b;
if (b != 0)
{
res = a / b;}
cout << "Div = " << res << endl;
else
cout << "ERROR!!! Division by zero" << endl;break;
cout << "Enter correct answer" << endl;}
break;
system("pause");
Комментариев нет:
Отправить комментарий