Answered step by step
Verified Expert Solution
Question
1 Approved Answer
I'm confused on how to limit the time of tries. Am I going to have a for loop? Can you show me the code??? Appreciated!
I'm confused on how to limit the time of tries. Am I going to have a for loop? Can you show me the code??? Appreciated!
GuessingGame.java) Write a program that generates a random number and asks the user to guess what the number is. If the user's guess is incorrect, the program should display "too high, try again" or "too low, try again" Repeat until the user has guessed correctly or exceeded the number of attempts. The program should issue a final message indicating the number was guessed and the number of attempts it took, or the number that was not guessed 1. This program will run at the command prompt (using System.out.println and Scanner) The upper limit of number to be guessed and the max number of guesses should be constant values. I should be able to change those two constants and the rest of the program will operate properly (including output statements) In my example, the max number of guesses is 5, the high value is 100. No use of methods others than main) required Sample program run #1: I'm thinking of a number between 1 and 100 You have 5 tries to guess it Guess 1: 50 Sorry, that's too high. Guess again: 25 No, that's too low Guess again: 35 No, that's too low Guess again: 40 No, that's too low Guess again: 45 You are out of guesses. I was thinking of the number 49Step 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