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 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
|
#include<iostream>
#include<string>
using namespace std;
float mult(float num1,float num2);
float add(float num1,float num2);
float sub(float num1,float num2);
float divide(float num1,float num2);
int main()
{
int choice;
float num1,num2;
cout<<"---------------------------------------------"<<endl;
cout<<"---------------------------------------------"<<endl;
cout<<" ---------Nii's CALCULATOR!!!!!-----"<<endl;
cout<<"---------------------------------------------"<<endl;
cout<<"---------------------------------------------"<<endl;
cout<<" Make a selection:"<<endl;
cout<<" 1.Division"<<endl;
cout<<" 2.Adding"<<endl;
cout<<" 3.Subtraction"<<endl;
cout<<" 4.multiplication"<<endl;
cout<<
cout<<"";YOUR CHOICE IS:;
cin>>choice;
switch(choice){
case 1:
cout<<Please enter the two numbers you want to
divide, divisor first!: ;
cin>>num1>> num2;
cin.ignore();
cout<<
"<<num1<<"/"<<num2<<"=<<divide(num1,num2)<<endl;
break;
case 2:
cout<<Please enter the two numbers
you
want to add: ;
cin>>num1>> num2;
cin.ignore();
cout<<
"<<num1<<"+"<<num2<<"=<<add(num1,num2)<<endl;
break;
case 3:
cout<<Please enter
the
two numbers you want to subtract, The number you want to subtract from
first!: ;
cin>>num1>> num2;
cin.ignore();
cout<<
"<<num1<<"-"<<num2<<"=<<sub(num1,num2)<<endl;
break;
case 4:
cout<<Please
enter the two numbers you want to multiply: ;
cin>>num1>>
num2;
cin.ignore();
cout<<
"<<num1<<"*"<<num2<<"=<<mult(num1,num2)<<endl;
break;
default:
cout<<"Invalid Entry!, BYE!!!"<<endl;
cin.ignore();
break;
}
cin.ignore();
return 0;
}
float mult(float num1,float num2){
return (num1*num2);
}
float add(float num1,float num2){
return (num1+num2);
}
float sub(float num1,float num2){
return (num1-num2);
}
float divide(float num1,float num2){
return (num1/num2);
}
|