Advertisement
Touch_Grass

Script 1

Jan 7th, 2023
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.23 KB | Source Code | 0 0
  1. #include <iostream>
  2. #include <Windows.h>
  3. using namespace std;
  4. int main() {
  5.     bool Running, SyntaxLegal, Broken;
  6.     int Numb1, Numb2;
  7.     string Operator,Cont;
  8.     Running = true;
  9.     //Main loop(runs while var Running == true)
  10.     while (Running == true) {
  11.         Broken = false;
  12.         cout << "Enter first number>";
  13.         cin >> Numb1;
  14.         if (Broken == false) {
  15.             cout << "Enter Second number>";
  16.             cin >> Numb2;
  17.             cout << "Enter operator type(+,-,/,* are only accepted)>";
  18.             cin >> Operator;
  19.             system("cls");
  20.             SyntaxLegal = false;
  21.             if (Operator == "+") {
  22.                 SyntaxLegal = true;
  23.                 cout << "Answer: " << Numb1 + Numb2 << endl;
  24.             }
  25.             else if (Operator == "-") {
  26.                 SyntaxLegal = true;
  27.                 cout << "Answer: " << Numb1 - Numb2 << endl;
  28.             }
  29.             else if (Operator == "*") {
  30.                 SyntaxLegal = true;
  31.                 cout << "Answer: " << Numb1 * Numb2 << endl;
  32.             }
  33.             else if (Operator == "/") {
  34.                 SyntaxLegal = true;
  35.                 cout << "Answer: " << Numb1 / Numb2 << endl;
  36.             }
  37.             if (SyntaxLegal == false) {
  38.                 Beep(500,200);
  39.                 cout << "Syntax error(102): Arithmetic input given is illegal" << endl;
  40.             }
  41.             cout << "Continue?>";
  42.             cin >> Cont;
  43.             if (Cont == "N" or Cont == "Y") {
  44.                 Running = false;
  45.             }
  46.             system("cls");
  47.         }
  48.     }
  49.     return 0;
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement