解题思路:
注意事项:
输入字符的写法非nextChar()
正确写法为:next().charAt(0)
参考代码:
import java.util.Scanner; public class Main { public static void main(String args[]) { Scanner input = new Scanner(System.in); int x = input.nextInt(); int y = input.nextInt(); char t = input.next().charAt(0); switch (t) { case '+': System.out.printf("%d",x+y); break; case '-': System.out.printf("%d",x-y); break; case '*': System.out.printf("%d",x*y); break; case '/': System.out.printf("%d",x/y); break; case '%': System.out.printf("%d",x%y); break; default: break; } } }
0.0分
0 人评分