The use of computers in education is referred to as computer-assisted instruction (CAI). Write a program that will help an elementary-school student learn multiplication. Use the rand function to produce two positive one-digit integers. The program should then prompt the user with a question, such as How much is 6 times 7? The student then inputs the answer. Next, the program checks the student’s answer. If it’s correct, display the message "Very good!" and ask another multiplication question. If the answer is wrong, display the message "No. Please try again." and let the student try the same question repeatedly until the student finally gets it right. A separate function should be used to generate each new question. This function should be called once when the application begins execution and each time the user answers the question correctly.   i made this code so far : //Name: IhabAtouf //Date:02/23/2023 // exercise 6.57 on page 281 //program description: create computer-assisted instruction (CAI) program that help students master thier math skills in multiplications, // multiplication involving two numbers each is a single digit positive, with encouraging message for succedding and another for failing to answer  // using random fucntion (rand) to generate a random number every time  #include// to be able to use input output stream #include//h is a header file in the standard library of the C programming language designed for basic mathematical operations #include//Converts a string into a long integer, also carry the library for definition of memory allocation and random processe #include//converts the given time since epoch to a calendar local time and then to a character representation. using namespace std;//using the standard library  int answer;//global varibale that can be used by any function in this code void questionGenerator() {//the function that generates the multiplication question      srand(time(NULL));// using the random function that changes every time per second      //here is the initial variable as zero by default      int initial = 0;     // here is two vraibales number1 and number2 that are required to multiply two numbers      int number1;     int number2;     number1 = (initial + (rand()) % 10);//the value of number1 using the follwing math : zero + any random number that has remainder of 10 using the remainder modulus     number2 = (initial + (rand()) % 10);//the value of number2 using the follwing math : zero + any random number that has remainder of 10 using the remainder modulus     answer = number1 * number2;// the asnwer variable that equals  the multiplication of those two numbers (number1 and 2)     cout << "How much is  " << number1 << " times " << number2 << " ?" << endl;//print how much is number 1 multiplied by number 2 ? } int main() {// the main function      int studentResponse=1;// declaring local variable called student response      questionGenerator();// calling the question generator function      while (studentResponse != -1){// as long as the student response not equal to -1 then:              cout << "Enter the correct answer" << endl;// print enter the correct answer statement          cin >> studentResponse;// allow user to input the student response variables value          if (answer == studentResponse) {//if the studenrt response entered by user equal the answer variable of multiplying those two numbers1 and number2 variables              cout << "Very Good!" << endl;// then print very good statement              questionGenerator();// then recall the function again for the net set of random numebrs multiplication              continue;// continue till user unout incorrect answer or -1         }         else {// otherwise when answer not correct then print please try again statement              cout << "Please try again!" << endl;                      }         return 0;     } }   my problem is when the user give the wrong answer the program exits: i need the code to not exit and to allow the ser to try to answer repeatedly till the user gives the right answer  help me make a loop after the (else) statement to allow the student try the same question repeatedly until the student finally gets it right i already posted this question and the code and supposibly the EXPERT answered back by reposting my code without fixing my issue

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter5: Control Structures Ii (repetition)
Section: Chapter Questions
Problem 30PE
icon
Related questions
Question

 The use of computers in education is referred to as computer-assisted instruction (CAI). Write a program that will help an elementary-school student learn multiplication. Use the rand function to produce two positive one-digit integers. The program should then prompt the user with a question, such as How much is 6 times 7?
The student then inputs the answer. Next, the program checks the student’s answer. If it’s correct, display the message "Very good!" and ask another multiplication question. If the answer is wrong, display the message "No. Please try again." and let the student try the same question repeatedly until the student finally gets it right. A separate function should be used to generate each new question. This function should be called once when the application begins execution and each time the user answers the question correctly.

 

i made this code so far :

//Name: IhabAtouf
//Date:02/23/2023
// exercise 6.57 on page 281
//program description: create computer-assisted instruction (CAI) program that help students master thier math skills in multiplications,
// multiplication involving two numbers each is a single digit positive, with encouraging message for succedding and another for failing to answer 
// using random fucntion (rand) to generate a random number every time 

#include<iostream>// to be able to use input output stream
#include<math.h>//h is a header file in the standard library of the C programming language designed for basic mathematical operations
#include<cstdlib>//Converts a string into a long integer, also carry the library for definition of memory allocation and random processe
#include<ctime>//converts the given time since epoch to a calendar local time and then to a character representation.
using namespace std;//using the standard library 

int answer;//global varibale that can be used by any function in this code

void questionGenerator() {//the function that generates the multiplication question 
    srand(time(NULL));// using the random function that changes every time per second 

    //here is the initial variable as zero by default 
    int initial = 0;
    // here is two vraibales number1 and number2 that are required to multiply two numbers 
    int number1;
    int number2;

    number1 = (initial + (rand()) % 10);//the value of number1 using the follwing math : zero + any random number that has remainder of 10 using the remainder modulus
    number2 = (initial + (rand()) % 10);//the value of number2 using the follwing math : zero + any random number that has remainder of 10 using the remainder modulus
    answer = number1 * number2;// the asnwer variable that equals  the multiplication of those two numbers (number1 and 2)
    cout << "How much is  " << number1 << " times " << number2 << " ?" << endl;//print how much is number 1 multiplied by number 2 ?
}
int main() {// the main function 
    int studentResponse=1;// declaring local variable called student response 
    questionGenerator();// calling the question generator function 
    while (studentResponse != -1){// as long as the student response not equal to -1 then:
    
        cout << "Enter the correct answer" << endl;// print enter the correct answer statement 
        cin >> studentResponse;// allow user to input the student response variables value 
        if (answer == studentResponse) {//if the studenrt response entered by user equal the answer variable of multiplying those two numbers1 and number2 variables 
            cout << "Very Good!" << endl;// then print very good statement 
            questionGenerator();// then recall the function again for the net set of random numebrs multiplication 
            continue;// continue till user unout incorrect answer or -1


        }
        else {// otherwise when answer not correct then print please try again statement 
            cout << "Please try again!" << endl;
            
        }
        return 0;


    }
}

 

my problem is when the user give the wrong answer the program exits:

i need the code to not exit and to allow the ser to try to answer repeatedly till the user gives the right answer 

help me make a loop after the (else) statement to allow the student try the same question repeatedly until the student finally gets it right

i already posted this question and the code and supposibly the EXPERT answered back by reposting my code without fixing my issue

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 3 images

Blurred answer
Knowledge Booster
Random Class and its operations
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning