To your first point :
Since, you have defined the following method to return an int.
It should be modified from:
CODE
public static int getnum(){
(int)((int)'1' + Math.random() * ((int)'100' - (int)'1' + 1);
}
to:
CODE
public static int getnum(){
return (int) (1 + Math.random() * (100 - 1 + 1)); //check the braces
}
See, the keyword return.
Also, when using integers you do not need to use ' ', these are only for characters.
To your third point ;) :
else if (g = t). To check the equality of values in Java you need to use the "==" operator. What you used here, is the assignment operator.
So, it should be like this :
else if (g == t)Also, your method getguess() should be returning an int.
add this as the last line of the code in that method:
return guess;One last thing :
public static void guessinggame(String[] args) if you think the name of the this method will make the program run, you are incorrect. To run a program you need to name the entry point of the program as main()
Change the name so it looks like :
public static void main(String[] args) Hope that helps you, but try to understand to learn faster. :)
This post has been edited by letthecolorsrumble: 17 Mar, 2008 - 03:28 AM