number guessing program

Jackie Dyer

Greenhorn

Posts: 2

posted 2 years ago

I have a beginning Java Program I have been working on that creates a number guessing program where the computer guesses a number that the user is thinking of within a certain range.
I so far have the program below, but need help getting rid of a few kinks/ adding features.
-First, I need to set it up so that the user will be prompted and give a range. It should run and produce something like this:
Welcome to this first-ever mind-guessing program!

Please pick a range (higher than 1 and no larger than 50): 32

You will choose a number between 1 and 32... and I will try to guess it.

With each of my guess, you will tell me whether I am too high (h or H),
too low (l or L), match (m or M), or you want to quit (q or Q). My
objective is to find the number using as few guesses as possible.

-Second, the game is supposed to give up and restart after failing the five, guesses, but for some reason, after it fails the fifth time, it prompts a fifth guess once again instead, then restarts after- I need to prevent this, so that it should look something like this:
My fourth guess is 17: h
My guess is too high?

Hmm...I have a feeling it's because your Countdown is actually -2 before the loop ends. You can try to watch that variable and see what it's value is through each iteration or adjust it to something a little easier to read.