Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /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! */
- #include <iostream>
- using namespace std;
- int main()
- {
- int num1; //first number inputed
- int num2; //second number inputed
- char action; //The user defining what type of action to take
- cout << "Enter the first number: ";
- cin >> num1;
- cout << "Enter the second number: ";
- cin >> num2;
- if (num2 == 0) { cout << "Please put in a nonzero number!\n"; return 1; }
- action = 0;
- while (action != 'N')
- {
- cout << "Would you like to do:\n Addition(A), Subtraction(S), Multiplication(M), Remainder(R), \naVerage(V), check if the first number is Less than the second number(L), check if the first number is Greater than the second number(G), or None(N)?\n";
- cin >> action;
- if (action == 'A') { cout << "The sum is " << num1 + num2 << ".\n\n"; }
- else if (action == 'S') { cout << "The difference is " << num1 - num2 << ".\n\n"; }
- else if (action == 'M') { cout << "The product is " << num1 * num2 << ".\n\n"; }
- else if (action == 'R') { cout << "The remainder is " << num1 % num2 << ".\n\n"; }
- else if (action == 'V') { cout << "The average is " << (num1 + num2)/2 << ".\n\n"; }
- else if (action == 'L')
- {
- if (num1 < num2) { cout << "The first number is less than the second number.\n\n"; }
- if (num1 > num2) { cout << "The first number is greater than the second number.\n\n";}
- }
- else if (action == 'G')
- {
- if (num1 < num2) { cout << "The first number is less than the second number.\n\n"; }
- if (num1 > num2) { cout << "The first number is greater than the second number.\n\n"; }
- }
- else if (action == 'N') { cout << "Okay we're done here!\n"; }
- else { cout << "Please put in one of the valid choices!\n"; }
- }
- cout << "Thanks for using Gene's calculator! Have a nice day!" << endl;
- system("PAUSE");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement