This is what I have so far I just need help compiling it and finishing the print
ID: 3624313 • Letter: T
Question
This is what I have so far I just need help compiling it and finishing the printResult and other errors
#include
using namespace std;
void findResult(int, int, int); //based on user input, find the appropriate result
void printResult(int, double); //prints out the results of the calculation performed
int menu(); //lists the options available to the user
int main(){
//variable declarations
int choice; //variable receiving the user's menu choice.
int input1, input2;
cout<<"Enter the first number: ";
cin>>input1;
cout<<"Enter the second number: ";
cin>>input2;
//print out the menu:
for (int counter = 0; counter<3; counter++){
choice = menu();
findResult(choice, input1, input2);
}
system("PAUSE");
return 0;
}
int result;
int choice;
int menu(){
cout<<"1)Find the smallest number ";
cout<<"2)Find the largest number ";
cout<<"3)Find the average ";
cout<<"4)Find the sum ";
cout<<"5)Find the product ";
cout<<"Your choice ";
cin>>choice;
}
int findResult(){
switch(menu){
case 1:
cout<<"Find the smallest number ";
break;
case 2:
cout<<"Find the largest number ";
break;
case 3:
cout<<"Find the average ";
break;
case 4:
cout<<"Find the sum ";
break;
case 5:
cout<<"Find the product ";
break;
default :
cout<<"Please choose 1-5 ";
break;
}
if(case 1){
if(input1
result=input1;
else if(input2
result=input2;
}
if(case 2){
if(input1>input2){
cout<
else if(input2>input1){
result=input2;
}
if(case 3){
result=((input1+input2)/2)
}
if(case 4){
result=(input1+input2);
}
if(case 5){
result=(input1*input2);
}
int printResult(){
int choice;
double;
}
Explanation / Answer
please rate - thanks
I had to change your functions
any problems message me
#include <iostream>
using namespace std;
double findResult(int, int, int); //based on user input, find the appropriate result
void printResult(double); //prints out the results of the calculation performed
int menu(); //lists the options available to the user
int main(){
//variable declarations
int choice; //variable receiving the user's menu choice.
int input1, input2;
double result;
cout<<"Enter the first number: ";
cin>>input1;
cout<<"Enter the second number: ";
cin>>input2;
//print out the menu:
for (int counter = 0; counter<3; counter++){
choice = menu();
result=findResult(choice, input1, input2);
printResult(result);
}
system("PAUSE");
return 0;
}
int menu(){
int result;
int choice;
do
{
cout<<"1)Find the smallest number ";
cout<<"2)Find the largest number ";
cout<<"3)Find the average ";
cout<<"4)Find the sum ";
cout<<"5)Find the product ";
cout<<"Your choice ";
cin>>choice;
if(choice<1||choice>5)
cout<<"Please choose 1-5 ";
}while(choice<1||choice>5);
return choice;
}
double findResult(int choice,int input1,int input2 ){
double result;
switch(choice){
case 1:if(input1<input2)
result=input1;
else
result=input2;
cout<<"Find the smallest number ";
break;
case 2:if(input1>input2)
result=input1;
else
result=input2;
cout<<"Find the largest number ";
break;
case 3:
cout<<"Find the average ";
result=((input1+input2)/2.);
break;
case 4:cout<<"Find the sum ";
result=(input1+input2);
break;
case 5:
cout<<"Find the product ";
result=(input1*input2);
break;
}
return result;
}
void printResult(double result){
cout<<"The result is: "<<result<<endl<<endl;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.