编写一个java程序实现如下功能

2025-04-06 14:39:54
推荐回答(1个)
回答1:

class zd {
int a, b;
Scanner sc = null;
public void s() {
sc = new Scanner(System.in);
a = sc.nextInt();
b = sc.nextInt();
try {
System.out.println(a / b);
} catch (ArithmeticException e) {
System.out.println("Divided by zero error!");
} catch (InputMismatchException e) {
System.out.println("Input type mismatch error!");
}
}

public static void main ( String args[] )
{
new zd().s();;
}
}