Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <iostream>
- #include <cstdlib>
- using namespace std;
- double Addition(double Num1, double Num2)
- {
- return Num1 + Num2;
- }
- double Subtraction(double Num1, double Num2)
- {
- return Num1 - Num2;
- }
- double Multiplication(double Num1, double Num2)
- {
- return Num1 * Num2;
- }
- double Division(double Num1, double Num2)
- {
- return Num1 / Num2;
- }
- int main()
- {
- double Number1;
- double Number2;
- int operation;
- char systempause;
- cout << "\n Welcome to this easy to use text-based calculator. \n" << endl;
- cout << "\n What would you like to do? \n" << endl;
- cout << "\n Press 1 for Addition. \n Press 2 for Subtraction. \n Press 3 for Multiplication. \n Press 4 for Division. \n" << endl;
- cin >> operation;
- if (operation==1)
- {
- cout << "\n You have chosen addition. Please input the first number. \n" << endl;
- cin >> Number1;
- cout << "\n The first number you have selected is " << Number1 << ". Please input the second number. \n" << endl;
- cin >> Number2;
- cout << "\n The answer is " << Addition(Number1, Number2) << endl;
- }
- else
- {
- if (operation==2)
- {
- cout << "\n You have chosen subtraction. Please input the first number. \n" << endl;
- cin >> Number1;
- cout << "\n The first number you have selected is " << Number1 << ". Please input the second number. \n" << endl;
- cin >> Number2;
- cout << "\n The answer is " << Subtraction(Number1, Number2) << endl;
- }
- else
- {
- if (operation==3)
- {
- cout << "\n You have chosen multiplication. Please input the first number. \n" << endl;
- cin >> Number1;
- cout << "\n The first number you have selected is " << Number1 << ". Please input the second number. \n" << endl;
- cin >> Number2;
- cout << "\n The answer is " << Multiplication(Number1, Number2) << endl;
- }
- else
- {
- if (operation==4)
- {
- cout << "\n You have chosen division. Please input the first number. \n" << endl;
- cin >> Number1;
- cout << "\n The first number you have selected is " << Number1 << ". Please input the second number. \n" << endl;
- cin >> Number2;
- cout << "\n The answer is " << Division(Number1, Number2) << endl;
- }
- else
- {
- cout << "\n The choice you have selected is invalid. Please re-open the program. \n" << endl;
- }
- }
- }
- }
- cout << "\n Thank you for using the program. \n";
- cin >> systempause;
- return 0;
- }
Add Comment
Please, Sign In to add comment