2. There is a secret organization and they want to create a secret language for the calculation to make the data secure. Now the manager of the organization asked his IT employee to make the program which will function as follows: a) * will subtract the numbers b) - will divide the numbers c) / will add the numbers d) + will multiply the numbers
#include <iostream>
#include <string>
using namespace std;
int main(){
float number1,number2,result;
int choice=-1;
while(choice!=5){
cout<<"1. Subtract the numbers\n";
cout<<"2. Divide the numbers\n";
cout<<"3. Add the numbers\n";
cout<<"4. Multiply the numbers\n";
cout<<"5. Exit\n";
cout<<"Your choice: ";
cin>>choice;
if(choice>=1 && choice<=4){
cout<<"Enter the number 1: ";
cin>>number1;
cout<<"Enter the number 2: ";
cin>>number2;
}
if(choice==1){
//Subtract the numbers
result=number1-number2;
cout<<"\n"<<number1<<" - "<<number2<<" = "<<result<<"\n\n";
}else if(choice==2){
// Divide the numbers
result=number1/number2;
cout<<"\n"<<number1<<" / "<<number2<<" = "<<result<<"\n\n";
}else if(choice==3){
//Add the numbers
result=number1+number2;
cout<<"\n"<<number1<<" + "<<number2<<" = "<<result<<"\n\n";
}else if(choice==4){
//Multiply the numbers
result=number1*number2;
cout<<"\n"<<number1<<" * "<<number2<<" = "<<result<<"\n\n";
}else if(choice==5){
//exit
}else{
cout<<"\nSelect correct menu item.\n";
}
}
system("pause");
return 0;
}
Comments
Leave a comment