System.out.println("Insert first number : ");
Scanner ad = new Scanner(System.in);
int y = ad.nextInt();
System.out.println("Insert Second Number: ");
Scanner er = new Scanner(System.in);
int x = er.nextInt();
int z;
z = x + y;
if (z > 10) {
System.out.println(z + " is greater than 10");
} else if (z < 9) {
System.out.println(z + " is less than 10");
} else {
System.out.println(z + " is equal to 10");
}
I want the output of each if statements to be error when I put character instead of numbers. And make an output appear that the character I have entered is invalid.