Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started