MasterChief:
>Ok, when the player is asked to enter a number, the program expects INT, but
>if I enter 0.5 (double) i get whole bunch of errors... how can i write the
>code to check for an integer?
If all you can accept are int values, just use parse approach I
mentioned. Something like this:
String userInput = ...; // get user string
int value;
try {
value = Integer.parseInt(userInput);
} catch (NumberFormatException nfe) {
System.err.println("Not a valid int value: " + userInput);
System.exit(1);
}
// if execution gets to this point, user has entered a valid int
// which is now in value
Regards,
Marco

Signature
Please reply in the newsgroup, not by email!
Java programming tips: http://jiu.sourceforge.net/javatips.html
Other Java pages: http://www.geocities.com/marcoschmidt.geo/java.html
nos - 31 Oct 2003 16:49 GMT
or you could use Double.parseDouble() which
handles int and double without error, then convert
result to int
> MasterChief:
>
[quoted text clipped - 22 lines]
> Java programming tips: http://jiu.sourceforge.net/javatips.html
> Other Java pages: http://www.geocities.com/marcoschmidt.geo/java.html