In Java, variables only have
scope between the { and } where they are declared.
Since you code
Code:
try {
int guess = scan.nextInt();
}
that variable is not accessible outside the
try block.
The solution is easy (and common!)
Code:
public static int guess(){
Scanner scan = new Scanner(System.in);
int guess;
try {
guess = scan.nextInt();
}
catch (InputMismatchException err) {
System.out.println("Your entry is not an integer between 1 and 100");
Guess.guess(); // if this is a recursive call, I think it's a bad idea
}
return guess;
}