for (int i = 1; i <= numberOfEntries; i++) { /* * Catch any and all errors (type mis-match errors) that way we don't * crash the user of this program :-) */ try { /* * Prompt the user to enter test score "i" */ System.out.print("Enter score " + i + ": "); /* * Grab the Integer */ testScore = sc.nextInt(); } catch(InputMismatchException e) { /* * Discard the invalid data entry */ sc.next(); /* * Notify the user of their mistake */ System.out.println("Invalid entry, not counted"); /* * Jump back into the loop */ continue; } }