import java.util.Scanner; public class Input2 { public static void main(String[] args) { System.out.print("Please click in the Console, "); System.out.print("type a number, and press ENTER: "); Scanner scanner = new Scanner(System.in); if (!scanner.hasNextInt()) { System.err.println("unable to read int"); System.exit(1); //unsuccessful termination } int i = scanner.nextInt(); System.out.print("Type another number, and press ENTER: "); if (!scanner.hasNextInt()) { System.err.println("unable to read int"); System.exit(1); } int j = scanner.nextInt(); scanner.close(); System.out.println("The sum is " + (i + j) + "."); System.exit(0); //successful termination } }