hmm here is the rest of my code. I know the last part is probably wrong but I can fix that once I get to compile it first since its a compile error and not a run-time error.
Code:
public static int getnum(int target){
// returns a random integer from 1-100
target = (int) (Math.random() * 100);
return target;
}
public static int getguess(int guess){
// asks the user for their guess, an integer from 1-100
String guessString = JOptionPane.showInputDialog(
"Enter an Integer between 0 and 100: ");
guess = Integer.parseInt(guessString);
// returns the guess
return guess;
}
public static void checkguess(int g, int t){
/** compares the user’s guess, passed in as parameter g, with
* the random target, passed in as parameter t.
* prints a message stating whether the guess is too high, too low,
* or an exact match (thus ending the game)
*/
String result;
if (g < t)
result = "Your guess is too low. Guess again! ";
else if (g > t)
result = " Your guess is too high. Guess again! ";
else if (g == t)
result = "You have guessed RIGHT! Congratulations!!!";
JOptionPane.showMessageDialog(null, result);
}