用有参数的方法写一个简单的计算器实例
package shujia.javabasicJuly5rd;
import java.util.Scanner;
public class Calculate {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int a=sc.nextInt();
String b=sc.next();
int c=sc.nextInt();
jsq(a,b,c);
}
public static void jsq(int i,String symble ,int j){
switch(symble){
case"+":
System.out.println(i+j);
break;
case "-":
System.out.println(i-j);
break;
case "*":
System.out.println(i*j);
break;
case"/":
System.out.println(i/j);
break;
}
}
}