Hi friends,
I have been assigned the following task for my begginer java course.
Write a program that will guess a number that the user thinks up based on the rules below:
1. You must ask the user to think of an integer between 1 and 1000. They do not type this number into the computer. They just think of it in their head.
2. The computer will make an initial guess of the number.
3. The user must indicate if the guess is too high, too low or correct (use whatever input format you want for this, but specify it in the comments and prompt, as usual).
4. If the computer has not guessed the right number, it should make another guess.
5. This process goes on until the computer guesses the user’s number. If you design your program correctly it should always guess the number in 10 tries or less.
6. Your program should also indicate how many guesses it took to guess the number.
Were supposed to limit which methods we use to the ones we learned in class, but basically I know that I need to create a method that generates a random number, then changes the range of random numbers to be between 1 or 1000 depending on user's answer, then continues to do so until the user's number is reached, at which point the method is not repeated and the amount of guesses is returned.
How do I generate a random number between a given range?