Scanner t = new Scanner(System.in);
int a, b, c, d;
do {
System.out.println("请输入第一个的值: ");
a = t.nextInt();
System.out.println("请输入第二个的值: ");
b = t.nextInt();
System.out.println("请输入第三个的值: ");
c = t.nextInt();
System.out.println("请输入第四个的值: ");
d = t.nextInt();
try {
System.out.println(a + "/" + b + "的余为 " + (a % b));
System.out.println(a + "+" + b + "= " + (a + b));
System.out.println(c + "/" + d + "的余为 " + (c % d));
System.out.println(c + "+" + d + "= " + (c + d));
} catch (ArithmeticException e) {
System.out.println("被除数为零 ");
}
} while (0 != a || 0 != b || c != d);
不知道是不是你想要的效果?
温馨提示:内容为网友见解,仅供参考