Question: Objective: Demonstrate use of a do...while loop for data validation and a for loop to process. Specifications: Write a program that lets the user play

Objective: Demonstrate use of a do...while loop for data validation and a for loop to process. Specifications: Write a program that lets the user play a simple math game that tests the user's ability to do simple multiplication. The user should be prompted to enter how many problems to solve. Use a do...while loop for input validation to prevent the user from entering a number less than 1. In a for loop, the program should generate 2 random numbers in the range 1 - 9. The numbers should be used in a prompt to the user, showing something that looks like an equation. The user will type in an answer to the problem. If the answer is correct, one message will appear; if the answer is incorrect, a different message should appear. An integer variable should be used to keep count of how many questions the user answered correctly. Final output will show how many problems the user answered correctly. Sample run: GUESS THE PRODUCT GAME How many times would you like to play the game? -4 Invalid entry. Please try again. How many times would you like to play the game? 3 What is 4 * 7? 28 Right! What is 6 * 8? 48 Right! What is 7 * 2 ? 5 Nope. Good job! You got 2 right! Process returned o (exe) Press any key to continue. execution time : 11.679 s
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
