Question
C++ Debug help!!!! PLEASE HELP I am not allowed to use global variables!! Phase 1 Write a program that prints a menu. Based on the
C++ Debug help!!!!
PLEASE HELP
I am not allowed to use global variables!!
Phase 1
Write a program that prints a menu. Based on the menu item selected by the user, the program should
request the required inputs from the user
call the appropriate function
print the functions result (from the main program NOT the function)
For example, if the user selections the sum function, then your program will ask them for two numbers to be added together, call the sum function, and finally print the sum functions result.
NOTE: In case of a typo on here make your output match the CA output!
The functions to implement are:
Simple Sum: Takes two int parameters and returns their sum. You will need to ask the user for two integers before calling this function.
Simple Division: Takes two int parameters and returns their floating point quotient (e.g., 10/3 returns 3.33). You will need to ask the user for two integers before calling this function.
Complex Division: Takes four int parameters, sums the first three parameters and then divides the sum by the fourth parameter. Returns the floating point quotient (e.g., (10 + 7 + 5) / 4 returns 5.5). You will need to ask the user for three integers and an integer divisor before calling this function.
(note - all function parameters will need to match the requirements of the assignment. - thus you do not use arrays in this assignment anywhere)
Design:
It is imperative that each of these three operations be in their own function.
You should have an additional function that determines the operation type by printing the menu and then returning the integer that the user selects.
Your main program should use a switch statement that switches on the numeric integer entered by the user to select the correct function to call.
Your switch statement should also gather the inputs from the user before calling the function.
You will print the result returned by the function in your switch statement.
All function prototypes will be listed at the top of your code (after using namespace std;) and all your function definitions to be placed after main.
Please help me debug the code I have written for this so far. My Do while is not working, it is supposed to keep running that loop multiple times so the user can do multiple operations. I am not sure how to do this. Also I am having an error with simple division "Invalid operands of types int and to binary operator<< "
#include #include using namespace std;
int main(){
int menu(); int SimpleSum(int, int); double SimpleDivision(int, int); //double ComplexDivision(int, int, int, int);
int int_1; int int_2;
switch(menu()) { case 1: cout << "Please enter two integers:" << endl; cin >> int_1; cin >> int_2; SimpleSum(int_1, int_2); cout << "sum = " << SimpleSum(int_1, int_2) << endl; break;
case 2: cout << "Please enter two integers: " << endl; cin >> int_1; cin >> int_2; SimpleDivision(int_1, int_2) << endl; cout << "quotient = " << SimpleDivision(int_1, int_2); break; /* case 3: ComplexDivision(); break; */ } return 0; }
////////////////////////////////////////////////////////////////// int menu() {
int menu_choice;
do{
cout << "Please make a selection from the following menu"<< endl; cout << endl; cout << "1. Simple Sum " "2. Simple Division " "3. Complex Division " "4. Quit " << endl;
cout << "Enter the number of the operation you wish to perform: " ; cin >> menu_choice; return menu_choice;
} while (menu_choice != 4); return 0;
}
///////////////////////////////////////////////////////////////////
int SimpleSum(int int_1, int int_2){
int sum;
sum = int_1 + int_2;
return sum ; }
///////////////////////////////////////////////////////////////////
double SimpleDivision( int int_1, int int_2){
double quotient;
quotient = (int_1 / int_2) ;
return quotient;
} ///////////////////////////////////////////////////////////////////
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started