I'm trying to print a message saying "Wrong", followed by another chance to enter the value every time the user enters something that's not an int. 

I have the following code:

```
do {

    System.out.println("Enter last name: ");
    lastName = input.next();

    System.out.println("Enter first name: ");
    firstName = input.next();

    do {
        System.out.println("Enter exam 1 score: ");
        if (input.hasNextInt()) {
            ex1 = input.nextInt();

            System.out.println("Enter exam 2 score: ");
            ex2 = input.nextInt();

            System.out.println("Enter exam 3 score: ");
            ex3 = input.nextInt();

            valid = true;

        } else {
            System.out.println("Incorrect choice. Write the score in numbers." + "\n");
            valid = false;
            input.next(); // Prevents infinite loop
        }
    } while (!valid);

```

which seems to work fine only if the user makes a mistake for exam 1, but if they do it on exam 2 or 3, it gives me an error.

I'll appreciate your help.