Question: Please compile this code for me; __________________________________________________________ #include #include #include using namespace std; void generateQuestion(int &x, int &y); bool checkAnswer(int x, int y, int answer);

Please compile this code for me;

__________________________________________________________

#include #include #include

using namespace std;

void generateQuestion(int &x, int &y); bool checkAnswer(int x, int y, int answer); void displayResult(int correctAnswers, int totalAnswers);

int main() { srand(time(0)); int x, y, answer; int correctAnswers = 0; int totalAnswers = 0;

for (int i = 0; i < 10; i++) { generateQuestion(x, y); cout << "How much is " << x << " times " << y << "? "; totalAnswers++; cin >> answer;

while (!checkAnswer(x, y, answer) && i<9) { i++; cout << "No. Please try again." << endl; cout << "How much is " << x << " times " << y << "? "; totalAnswers++; cin >> answer; } cout<

return 0; }

void generateQuestion(int &x, int &y) { x = rand() % 10 + 1; y = rand() % 10 + 1; }

bool checkAnswer(int x, int y, int answer) { return x * y == answer; }

void displayResult(int correctAnswers, int totalAnswers) { int percentage = ((correctAnswers*100) / (10.0)) ; if (percentage < 75) { cout << "Please ask your teacher for extra help." << endl; } else { cout << "Congratulations, you are ready to go to the next level!" << endl; } }

__________________________________________________________________

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!