int result = 0; System.out.println("请输入一个整数:"); Scanner numInput = new Scanner(System.in); int num1 = numInput.nextInt(); System.out.println("请再输入一个整数:"); Scanner numInput1 = new Scanner(System.in); int num2 = numInput1.nextInt(); System.out.println("请输入一个算数运算符:"); Scanner operationInput = new Scanner(System.in); char op = operationInput.next().charAt(0); switch (op) { case '+': result = num1 + num2; break; case '-': result = num1 - num2; break; case '/': result = num1 / num2; break; case '*': result = num1 * num2; break; default: System.out.println("参数输入错误!"); return; } System.out.println("计算结果为:" + result);
?