Answer to Question #180477 in C++ for RAMAKRISHNA

Question #180477

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


1
Expert's answer
2021-04-12T02:27:32-0400
#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;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS