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 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
|
#include <cstdlib>
#include <iostream>
using namespace std;
float addition(float num1, float num2)
{
return num1 + num2;
}
float subtraction(float num1, float num2)
{
return num1 - num2;
}
float multiplication(float num1, float num2)
{
return num1 * num2;
}
float division(float num1, float num2)
{
return num1 / num2;
}
int main()
{
float num1;
float num2;
int choice;
cout<<"Choose your operation, 1= add, 2=subtract, 3=multiply, 4=divide" <<endl;
cout<<"Choice: ";
cin>>choice;
if(choice==1)
{
//Addition section
cout<<"you are adding, please enter the first number you would like to add. \n Number 1: ";
cin>>num1;
cout<<"please enter the second number you would like to add. \n Number 2: ";
cin>>num2;
cout<< "The answer is " << addition(num1, num2) <<endl;
}
else
{
if(choice==2)
{
//Subraction
cout<<"you are now subtraction, please enter the first number. \n Number 1: ";
cin>>num1;
cout<<"enter the next number. \n Number 2: ";
cin>>num2;
cout<< "the answer is: " << subtraction(num1, num2) <<endl;
}
else
if(choice==3)
{
//Multiplying
cout<<"you are multiplying, enter the first number. \n Number 1: ";
cin>>num1;
cout<<"please enter the second number. \n Number 2: ";
cin>>num2;
cout<<"the answer is: " <<multiplication(num1, num2) <<endl;
}
else
if(choice==4)
{
//division
cout<<"you are dividing, enter the first number. \n Number 1: ";
cin>>num1;
cout<<"enter the second number. \n Number 2: ";
cin>>num2;
cout<<"the answer is: "<<division(num1, num2)<<endl<<endl;
}
}
system("PAUSE");
return 0;
}
|