I'm having a severe brain drain moment and can't figure out how to validate user input? I need to make sure that it is an int and it is greater than 2. And I need it to loop until the user meets those requirements. I tried a try-catch block but it doesn't seem to be doing what I want. Any suggestions??
try {
System.out.println("Please enter the value for ps");
ps = sc.nextInt();
} catch (InputMismatchException e)
{
System.out.println("please inter an integer");
}
if (ps <= 1) {
System.out
.println("The number must be larger than 2. Please re-enter it");
ps = sc.nextInt();
}