Basic Guidelines: The program should utilize the addition subtraction additional
ID: 3729068 • Letter: B
Question
Basic Guidelines: The program should utilize the addition subtraction additional operations you may do so. However, make sure that your basic operations. Your program must include documentation inside the program. should/supposed to do. Hint: I would either have this information come up multiplication and division operations. If your team chooses to add operations work, and work well before moving on to any additional This includes comments within the code and a function with what year code automatically when the program is first ran or have this as a selection statement along with a choice of your operations. Basic Input/Output: Your program should get input, however you want, of what operation the user chooses to do. The user will also need to input two numbers in your program to be calculated in the operation. Basic Expectations (coding): You are to use functions including: function prototype function call end the function definitions. You are also to use any selection statements and any looping statements that you wish Grading Criteria: see Laboratory Document for grading Rubric. Extra Credit: Extra credit will be given to those programs that goes above and beyond just the basics. A cap of 10 points will be given.Explanation / Answer
#include<iostream>
using namespace std;
void showMenu();
int getOption(int selection);
void getNumbers(int& num1, int&num2);
int addNumbers(int num1, int num2);
int divideNumbers(int num1, int num2);
int subtractNumbers(int num1, int num2);
int multiplyNumbers(int num1, int num2);
void displayResults();
int main ()
{
displayResults();
/*system("pause");*/
return 0;
}
void showMenu()
{
cout<<"Enter---" <<endl;
cout<<" 1: To add two numbers."<<endl;
cout<<" 2: To divide two numbers. " <<endl;
cout<<" 3: To subtract two number. " <<endl;
cout<<" 4: To multiply two number. " <<endl;
cout<<"99: To quit the program." <<endl;
}
int getOption(int selection)
{
cin>>selection;
return selection;
}
void getNumbers(int& num1, int&num2)
{
cout<<"Enter two numbers: ";
cin>>num1 >>num2;
}
int addNumbers(int num1, int num2)
{
return num1+num2;
}
int divideNumbers(int num1, int num2)
{
return num1/num2;
}
int subtractNumbers(int num1, int num2)
{
return num1 - num2;
}
int multiplyNumbers(int num1, int num2)
{
return num1 * num2;
}
void displayResults()
{
int num1, num2, sum, choice;
do
{
showMenu();
cin>>choice;
cout<<endl;
switch (choice)
{
case 1:
getNumbers(num1, num2);
sum=addNumbers(num1, num2);
cout<<num1 <<" + " <<num2 <<" = " <<sum <<" ";
system("pause");
system("cls");
break;
case 2:
getNumbers(num1, num2);
sum=divideNumbers(num1, num2);
cout<<num1 <<" / " <<num2 <<" = " <<sum <<" ";
system("pause");
system("cls");
break;
case 3:
getNumbers(num1, num2);
sum=subtractNumbers(num1, num2);
cout<<num1 <<" - " <<num2 <<" = " <<sum <<" ";
system("pause");
system("cls");
break;
case 4:
getNumbers(num1, num2);
sum=multiplyNumbers(num1, num2);
cout<<num1 <<" * " <<num2 <<" = " <<sum <<" ";
system("pause");
system("cls");
break;
default:
cout<<"Invalid input. Try again!" << " ";
system("Pause");
}
} while (choice == 1 || choice == 2 || choice ==3 || choice == 4);
}