You need to display the error message in catch block
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int min = 0;
boolean repeat = true;
do {
//gonna ask for input if it is wrong or if they enter something more than 2
System.out.println("press 1 for days or 2 for years");
try {
min = input.nextInt();
repeat = false;
if (min > 2) //error when its not 1 or 2
{
repeat = true;
System.out.println("Either enter 1 or 2 ");
}
} catch (Exception a) //we will catch the error and then make it repeat the whole progress
{
repeat = true;
System.out.println("input an integer");
input.next();
}
} while (repeat == true);
}