I need help :(

Status
Not open for further replies.

skullker

Solid State Member
Messages
11
I need help with java loops

i am making a program where they try to guess a number between 1 and 100 and i have it all but i cant figure out how to make a loop where if the number they enter is greater than answer than it tells them "your too high" and if the number they enter is too low it tells them "your to low" then they try again it repeats until they get it

so how would i do the loop
 
I haven't done a whole lot of programming (I've only used my TI-84, and a little bit of C), but I think this should do it:
make the guessed number, and the randomly picked number to be different variables (for example X for guessed number, Y for randomly picked number)

then do something like this:

If X>Y
Print "Too high"
If X<Y
Print "Too Low"
 
first you'd have to define the variable(s), and then input the guessing number as a variable, then do the if statement.
 
Status
Not open for further replies.
Back
Top Bottom