Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <Windows.h>
- using namespace std;
- int main() {
- bool Running, SyntaxLegal, Broken;
- int Numb1, Numb2;
- string Operator,Cont;
- Running = true;
- //Main loop(runs while var Running == true)
- while (Running == true) {
- Broken = false;
- cout << "Enter first number>";
- cin >> Numb1;
- if (Broken == false) {
- cout << "Enter Second number>";
- cin >> Numb2;
- cout << "Enter operator type(+,-,/,* are only accepted)>";
- cin >> Operator;
- system("cls");
- SyntaxLegal = false;
- if (Operator == "+") {
- SyntaxLegal = true;
- cout << "Answer: " << Numb1 + Numb2 << endl;
- }
- else if (Operator == "-") {
- SyntaxLegal = true;
- cout << "Answer: " << Numb1 - Numb2 << endl;
- }
- else if (Operator == "*") {
- SyntaxLegal = true;
- cout << "Answer: " << Numb1 * Numb2 << endl;
- }
- else if (Operator == "/") {
- SyntaxLegal = true;
- cout << "Answer: " << Numb1 / Numb2 << endl;
- }
- if (SyntaxLegal == false) {
- Beep(500,200);
- cout << "Syntax error(102): Arithmetic input given is illegal" << endl;
- }
- cout << "Continue?>";
- cin >> Cont;
- if (Cont == "N" or Cont == "Y") {
- Running = false;
- }
- system("cls");
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement