Create a C++ program for this Create the Following Menu in a loop so the menu wi
ID: 3800962 • Letter: C
Question
Create a C++ program for this
Create the Following Menu in a loop so the menu will continually show until the user chooses to exit. 1. Add 2. Multiply 3. Exit Add a value returning function to menu option 1 and menu option 2. This means that you will create two functions: an Addition function and a Multiplication function. The functions will receive two doubles and return a double. *******Example of program running:******** 1. Add 2. Multiply 3. Exit Enter an option: 1 Enter a number: 10 Enter another number: 20.5 The sum of 10 and 20.5 is 30.5Explanation / Answer
// Header Files
#include<iostream>
#include<conio.h>
//Standard namespace declaration
using namespace std;
//Main Function
int main()
{
int choice;
double num1,num2;
cout<<" 1. Add";
cout<<" 2. Multiply";
cout<<" 3. Exit";
cout<<"Enter an option:";
cin>>choice;
switch(choice)
{
case 1:
cout<<"Enter a number";
cin>>num1;
cout<<"Enter another number";
cin>>num2;
double sum = add(num1,num2);
cout<<"Sum of "<< num1<<"and "<<num2<< " is "<< sum;
break;
case 2:
cout<<"Enter a number";
cin>>num1;
cout<<"Enter another number";
cin>>num2;
double mul = multi(num1,num2);
cout<<"Multiplcation of "<< num1<<"and "<<num2<< " is "<< mul;
break;
case 3:
exit(0);
}
// Wait For Output Screen
getch();
//Main Function return Statement
return 0;
}
//add method
double add(a,b)
{
double temp;
temp= a+b;
return temp;
}
//multiplication method
double multi(a,b)
{
double temp;
temp= a*b;
return temp;
}