help needed on inputting - tearing hair out .. please!!!
- From: "patrick_woflian" <gingercrock@xxxxxxxxxxx>
- Date: 28 Nov 2005 08:16:49 -0800
hey guys, i need help with a very annoying problem...
i am doing a program where the user inputs whether they think a random
number will be higher or lower than their own guess if it is not
correct... the problem im having is with the following code:
System.out.print(" Do you think the next number will be higher HI or
lower LO than " + x );
int y = in.nextInt();
String guess = in.nextString();
boolean correct = false;
if (guess.equals("HI"))
{
correct = (guess > y);
}
else if (guess.equals("LO"))
{
correct = (guess < y);
}
System.out.println("The number was " + y + " and you guessed " +
guess + " so you " + (correct ? "ROCK!" : "SUCK!"));
the main problem on the compiler is to do with string and guess....any
ideas what to do? my hair can't take anymore pulling..
.
- Follow-Ups:
- Re: help needed on inputting - tearing hair out .. please!!!
- From: Michael Redlich
- Re: help needed on inputting - tearing hair out .. please!!!
- Prev by Date: Re: read keyboard input and storing in an array?
- Next by Date: Re: Importing data file into a Java Applet
- Previous by thread: Help with threads
- Next by thread: Re: help needed on inputting - tearing hair out .. please!!!
- Index(es):
Relevant Pages
|