1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
|
#include "iostream"
#include "conio.h"
#include "string"
using namespace std;
int Addition(int x, int y);
int Subtraction(int x, int y);
int Division(int x, int y);
int Multiply2(int x, int y);
int main(){
int num1;
int num2;
string mathType;
do{
cout << "Would you like to add, subtract, divide, or multiply : " << endl;
cin >> mathType;
cout << "Enter the first number you wish to " << mathType << ":" << endl;
cin >> num1;
cout << "Enter the second number you wish to " << mathType << ":" << endl;
cin >> num2;
system ("cls");
if (mathType =="add"){
cout << num1 << " + " << num2 << " = " << Addition(num1, num2) << endl;
}
if (mathType == "subtract"){
cout << num1 << " + " << num2 << " = " << Subtraction(num1, num2) << endl;
}
if(mathType == "divide"){
cout << num1 << " - " << num2 << " = " << Division(num1, num2) << endl;
}
if(mathType == "multiply"){
cout << num1 << " * " << num2 << " = " << Multiply2(num1, num2) << endl;
}
_getch();
}while (1);
}
int Addition(int x, int y){
int numAnswer;
numAnswer = x + y;
return numAnswer;
}
int Subtraction(int x, int y){
int numAnswer;
numAnswer = x - y;
return numAnswer;
}
int Division(int x, int y){
int numAnswer;
numAnswer = x / y;
return numAnswer;
}
int Multiply2(int x, int y){
int numAnswer;
numAnswer = x * y;
return numAnswer;
}
|