Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

C++ Help Computers are playing an increasing role in education. Write a program

ID: 3674901 • Letter: C

Question

C++ Help

Computers are playing an increasing role in education. Write a program that will help an elementary school student learn multiplication. Use rand to produce two positive one-digit integers. The program should then output a question using the numbers, such as:

How much is 6 times 7?

The student then types the answer. The program checks the student’s answer. If it is correct, print "Very good!", and ask another multiplication question. If the answer is wrong, print "No. Please try again.", and let the student try the same question repeatedly until the student gets it right.

Hints:

• Use sentinel-controlled repetition to limit the number of questions that the program asks the user. At the same time, check that the user has entered the correct answer. • Seed the rand function with srand to randomize the program

• Sample output:

Enter -1 to End.

How much is 4 times 9 (-1 to End)?

36 Very good!

How much is 7 times 0 (-1 to End)?

0 Very good! How much is 7 times 8 (-1 to End)? 55

No. Please try again. ?

56 Very good!

How much is 5 times 0 (-1 to End)? -1

That's all for now. Bye.

Explanation / Answer

Please find the required solution:

#include <iostream>
#include <ctime>
#include <cstdlib>
using namespace std;

int main()
{
srand(time(NULL));
int operand1,operand2,input;
cout<<"enter -1 to end"<<endl;
do
{
operand1=rand()%10;
operand2=rand()%10;
cout<<"How much is "<<operand1<<" times "<<operand2<<"(-1 to end):";
cin>>input;
while(input!=(operand1*operand2) && input!=-1)
{
cout<<"No, Please try again"<<endl;
cin>>input;
}
if(input!=-1)
cout<<"Very Good"<<endl;
}while(input!=-1);
cout<<"That's all for now. Bye.";
return 0;
}

enter -1 to end                                                                                                                                                                       

How much is 9 times 9(-1 to end):99                                                                                                                                                   

No, Please try again                                                                                                                                                                  

81                                                                                                                                                                                    

Very Good                                                                                                                                                                             

How much is 9 times 6(-1 to end):54                                                                                                                                                   

Very Good                                                                                                                                                                             

How much is 1 times 8(-1 to end):8                                                                                                                                                    

Very Good                                                                                                                                                                             

How much is 0 times 7(-1 to end):7                                                                                                                                                    

No, Please try again

0   

Very Good How much is 1 times 4(-1 to end):-1

That's all for now. Bye.

Sample output

enter -1 to end                                                                                                                                                                       

How much is 9 times 9(-1 to end):99                                                                                                                                                   

No, Please try again                                                                                                                                                                  

81                                                                                                                                                                                    

Very Good                                                                                                                                                                             

How much is 9 times 6(-1 to end):54                                                                                                                                                   

Very Good                                                                                                                                                                             

How much is 1 times 8(-1 to end):8                                                                                                                                                    

Very Good                                                                                                                                                                             

How much is 0 times 7(-1 to end):7                                                                                                                                                    

No, Please try again

0   

Very Good How much is 1 times 4(-1 to end):-1

That's all for now. Bye.