Advertisement
minusX

Untitled

Nov 7th, 2013
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.82 KB | None | 0 0
  1. /*This is a advanced command line calculator that ask for two numbers and what you want to do with   two numbers.  It's kinda boring but that's fine!                           */
  2.  
  3.  
  4. #include <iostream>
  5. using namespace std;
  6. int main()
  7. {
  8.     int num1; //first number inputed
  9.     int num2; //second number inputed
  10.     char action; //The user defining what type of action to take
  11.  
  12.  
  13.     cout << "Enter the first number: ";
  14.     cin >> num1;
  15.     cout << "Enter the second number: ";
  16.     cin >> num2;
  17.     if (num2 == 0) { cout << "Please put in a nonzero number!\n"; return 1; }
  18.    
  19.     action = 0;
  20.     while (action != 'N')
  21.     {
  22.         cout << "Would you like to do \nAddition(A) \nSubtraction(S) \nMultiplication(M) \nRemainder(R) \naVerage(V) \ncheck if the first numeber is Less than the second number(L) \ncheck if the first numeber is Greater than the second number(G) \nor None(N)?\n";
  23.             cin >> action;
  24.             if (action == 'A') { cout << "The sum is " << num1 + num2 << ".\n\n"; }
  25.         if (action == 'S') { cout << "The difference is " << num1 - num2 << ".\n\n"; }
  26.         if (action == 'M') { cout << "The product is " << num1 * num2 << ".\n\n"; }
  27.         if (action == 'R') { cout << "The remainder is " << num1 % num2 << ".\n\n"; }
  28.         if (action == 'V') { cout << "The average is " << (num1 + num2)/2 << ".\n\n"; }
  29.         if (action == 'L')
  30.         {
  31.             if (num1 < num2) { cout << "The first number is less than the second number.\n\n"; }
  32.             if (num1 > num2) { cout << "The first number is greater than the second number.\n\n";}
  33.         }
  34.         if (action == 'G')
  35.         {
  36.             if (num1 < num2) { cout << "The first number is less than the second number.\n\n"; }
  37.             if (num1 > num2) { cout << "The first number is greater than the second number.\n\n"; }
  38.         }
  39.         else { cout << "Please put in one of the valid choices!\n"; }
  40.     }
  41.         cout << "Thanks for using this calculator!  Have a nice day!" << endl;
  42.         system("PAUSE");
  43.     return 0;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement