Using a while loop to prompt the user to enter 3 ints to average them out, need to reprompt when the input isn't an int, so I decided to take a step back in the loop when the input isn't an int, but when I enter a non int, it's as if it consistently goes to the condition that it isn't a int, and continues to reprompt, without rechecking for a new input.
Scanner scnr = new Scanner(System.in);
String prompt = "Type an integer: ";
int num = 0;
int i = 0;
while (i < 3) {
System.out.print(prompt);
if (scnr.hasNextInt()) {
int input = scnr.nextInt();
num += input;
} else i -= 1;
i += 1;
}
double average = num / 3.0;
System.out.println("Average: " + average);