Question
Question 3 (5 points): Create a number guessing game program. The program should utilize a random number generator of type integer between 1 and 10.
Question 3 (5 points): Create a number guessing game program. The program should utilize a random number generator of type integer between 1 and 10. Call this variable secretNumber. The program should allow users to enter a number in order to guess what the secret number is. If the guessed number is greater than the secretNumber, the program should display the message "Guess Lower!". If the guessed number is lower than the secretNumber, the program should display the message "Guess Higher!". The program needs to run until the user correctly guesses the secretNumber. When the user guesses the number correctly, the program should display the message "You got it right! You win!".
Hint: Use an if-else statement within a while loop. You may find the programs in LISTING 5.5 (pp. 222 of the 8th edition) and LISTING 5.7 (pp. 231 of the 8th edition) useful.
Sample Output for Question 3: Guessing game begins!
Enter your guess number: 9 Guess Lower!
Enter your guess number: 3 Guess Higher!
Enter your guess number: 5 You got it right! You win! |
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