1 public static void main(String[] args) { 2 Scanner scanner = new Scanner(System.in); 3 System.out.println("输入:"); 4 int x = scanner.nextInt(); 5 char a = scanner.next().charAt(0); 6 int y = scanner.nextInt(); 7 switch (a){ 8 case '+': 9 sum(x,y); 10 break; 11 case '-': 12 sub(x,y); 13 break; 14 case '*': 15 mul(x,y); 16 break; 17 case '/': 18 div(x,y); 19 break; 20 default: 21 System.out.println("输入错误"); 22 } 23 } 24 public static void sum(int a,int b){ 25 System.out.println(a+b); 26 } 27 public static void sub(int a,int b){ 28 System.out.println(a-b); 29 } 30 public static void mul(int a,int b){ 31 System.out.println(a*b); 32 } 33 public static void div(int a,int b){ 34 System.out.println(((double)a/b)); 35 }
标签:int,练习,System,day10,计算器,println,static,public,out From: https://www.cnblogs.com/GUGUZIZI/p/16757853.html