My program takes input from a user, first number, operation ( + - * / ^) then a second number. When I enter 5 / 0 it says ERROR!!! Cannot divide by 0 . That's what its supposed to do. However, When I type in 5 / 5 which is 1 I get my error message.
do {
try {
if (opperation == "/" && num2 == 0);
throw new ArithmeticException();
} catch (ArithmeticException ae) {
System.out.println("ERROR !!! Cannot divide by 0");
}
System.out.println("Enter First Number");
num1 = scan.nextInt();
System.out.println("ENTER Opperation: ");
opperation = scan.next();
System.out.println("ENTER Second Number: ");
num2 = scan.nextInt();
} while (num2 == 0);