Scanner in = ...
String input = in.next();
int n;
n = Integer.parseInt(input);
The static parseInt method may throw a NumberFormatException if the string in input cannot be converted to an int.
This not a checked exception. Should the call to parseInt be in a try block of a try...catch construct?