write a Menu driven C++ application for the game that your pupils can use to imp
ID: 3909731 • Letter: W
Question
write a Menu driven C++ application for the game that your pupils can use to improve their arithmetic skills. once started the game should allow the play to perform to choose one option from the four presented options namely: 1. perform a modulus division of two numbers 2. perform multiplication of two numbers 3. perform substraction of two numbers 4. exist Upon selection of the operation they wish to undertake the program should allow the user to provide the required numbers of the operation. once values are provided, the program should ask the user what the response is when the desired operation is carried out on the two numbers. A user should be given two chances only try and guess the right response, if the exhaust the two chances they should be provided with right answer. If they guess correctly, they should be recommended with a message of congratulations. After this is done, the user should be provided with the menu requesting them to choose another operation to carry out or exist the program.
Explanation / Answer
PROGRAM
#include<iostream>
using namespace std;
// Implement menu() function
int menu()
{
int ch;
cout<<" ARITHEMATIC OPERATION GAME"<<endl;
cout<<" ---------------------------"<<endl;
cout<<"1. Perform a modulus division of two numbers"<<endl;
cout<<"2. Perform multiplication of two numbers"<<endl;
cout<<"3. Peform subtraction of two numbers"<<endl;
cout<<"4. Exit"<<endl;
cout<<" Your Choice: "; cin>>ch; // read choice
return ch; // return choice
}
int main()
{
int a,b,c,ch,ans1; // declare integer variables
while(1) // create infinity while loop
{
ch=menu(); // calling menu() function and receive choice into ch
switch(ch) // declare switch statement
{
case 1: {
for(int i=1;i<=2;i++) // create for loop until two chances
{
cout<<" Solve 5 mod 2= "; // display question
cin>>ans1; // take answer from user
a=5; b=2; // assign value of a and b
if(5%2==ans1) { // check condition answer is correct then display congratualation message
cout<<"Congratualations.."<<endl;
break;
}
}
cout<<" Answer is: "<<a%b<<endl; // display actual answer
} break;
case 2: {
for(int i=1;i<=2;i++) // create for loop until two chances
{
cout<<" Solve 5*2= "; // display question
a=5; b=2; // assign value of a and b
cin>>ans1; // take answer from user
if(a*b==ans1) // check condition answer is correct then display congratualation message
{
cout<<"Congratualations.."<<endl;
break;
}
}
cout<<" Answer is: "<<a*b<<endl; // display actual answer
} break;
case 3: {
for(int i=1;i<=2;i++) // create for loop until two chances
{
cout<<" Solve 45-32="; // display question
a=45; b=32; // assign value of a and b
cin>>ans1; // take answer from user
if((a-b)==ans1) // check condition answer is correct then display congratualation message
{
cout<<"Congratualations.."<<endl;
break;
}
}
cout<<" Anser is: "<<(a-b)<<endl; // display actual answer
} break;
case 4: exit(0); break; // exit from this program
default: cout<<" Your Enter Wrong choice..."<<endl;
}
}
}
OUTPUT
ARITHEMATIC OPERATION GAME
---------------------------
1. Perform a modulus division of two numbers
2. Perform multiplication of two numbers
3. Peform subtraction of two numbers
4. Exit
Your Choice: 1
Solve 5 mod 2= 2
Solve 5 mod 2= 3
Answer is: 1
ARITHEMATIC OPERATION GAME
---------------------------
1. Perform a modulus division of two numbers
2. Perform multiplication of two numbers
3. Peform subtraction of two numbers
4. Exit
Your Choice: 1
Solve 5 mod 2= 1
Congratualations..
Answer is: 1
ARITHEMATIC OPERATION GAME
---------------------------
1. Perform a modulus division of two numbers
2. Perform multiplication of two numbers
3. Peform subtraction of two numbers
4. Exit
Your Choice: 2
Solve 5*2= 5
Solve 5*2= 10
Congratualations..
Answer is: 10
ARITHEMATIC OPERATION GAME
---------------------------
1. Perform a modulus division of two numbers
2. Perform multiplication of two numbers
3. Peform subtraction of two numbers
4. Exit
Your Choice: 3
Solve 45-32=65
Solve 45-32=26
Anser is: 13
ARITHEMATIC OPERATION GAME
---------------------------
1. Perform a modulus division of two numbers
2. Perform multiplication of two numbers
3. Peform subtraction of two numbers
4. Exit
Your Choice: 3
Solve 45-32=13
Congratualations..
Anser is: 13
ARITHEMATIC OPERATION GAME
---------------------------
1. Perform a modulus division of two numbers
2. Perform multiplication of two numbers
3. Peform subtraction of two numbers
4. Exit
Your Choice: 4
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.