0% found this document useful (0 votes)
15 views1 page

John Calcu

Uploaded by

mellowmars01
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views1 page

John Calcu

Uploaded by

mellowmars01
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 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