import java.util.Scanner;
import java.util.*;
public class ExceptionInAddition {
public static void main(String[] args) {
Scanner reader = new Scanner(System.in);
int firstNumber = 0, secondNumber = 0, result;
boolean inputCorrect = true;
do {
try {
System.out.println("Type in the first number: ");
firstNumber = reader.nextInt();
inputCorrect = true;
} catch (java.util.InputMismatchException p) {
inputCorrect = false;
}
} while (!inputCorrect);
do {
try {
System.out.println("Type in the second number: ");
reader.next();
inputCorrect = true;
} catch (java.util.InputMismatchException p) {
inputCorrect = false;
}
} while (!inputCorrect || (secondNumber == 0));
if (inputCorrect == true) {
result = firstNumber + secondNumber;
System.out.println("Result: " + result);
} else {
System.out.println("You did not type in an integer!");
}
}