John Calcu

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 1

#include <iostream>

#include <limits>
using namespace std;

int main() {
char op;
float num1, num2;
char again;

do {
cout << "Enter an operator (+, -, *, /): ";
cin >> op;

if (op != '+' && op != '-' && op != '*' && op != '/') {


cout << "ERROR 404!!!! (use an actual operator dummy!) >:(" << endl;
cin.clear();
cin.ignore(numeric_limits<streamsize>::max(), '\n');
continue;
}

cout << "Enter two numbers: ";


cin >> num1 >> num2;

switch (op) {
case '+':
cout << "The sum of " << num1 << " and " << num2 << " is: " << num1
+ num2 << endl;
break;
case '-':
cout << "The difference of " << num1 << " and " << num2 << " is: "
<< num1 - num2 << endl;
break;
case '*':
cout << "The product of " << num1 << " and " << num2 << " is: " <<
num1 * num2 << endl;
break;
case '/':
if (num2 != 0) {
cout << "The quotient of " << num1 << " and " << num2 << " is:
" << num1 / num2 << endl;
} else {
cout << "ERROR 404!!!! (divided by zero is undefined/impossible
dummy!) >:(" << endl;
}
break;
}

cout << "Another question mark? (y/n): ";


cin >> again;

} while (again == 'y' || again == 'Y');

return 0;
}

1373, 16839,17096

You might also like