JAVA
java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import java.util.Scanner;
import java.util.InputMismatchException;
public class Main {
@SuppressWarnings("resource")
public static void main(String[] args) throws ArithmeticException, InputMismatchException {
Scanner scanner = new Scanner(System.in);
try {
int num1 = scanner.nextInt();
int num2 = scanner.nextInt();
if (num1 == 0)
throw new ArithmeticException();
else
System.out.println(num1/num2);
} catch(ArithmeticException a) {
System.out.println("Error: division by zero");
} catch(InputMismatchException b) {
System.out.println("Error: wrong value type");
}
scanner.close();
}
}
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run