public static void main(String[] args) {
for (; ; ) {
Scanner scanner=new Scanner(System.in);
Scanner scanner1=new Scanner(System.in);
Scanner scanner2=new Scanner(System.in);
System.out.println(“请输入第一个数”);
int n = scanner.nextInt();
System.out.println(“请输入算法:1.加2.减3.乘4.除”);
int ffa = scanner1.nextInt();
System.out.println(“请输入第二个数”);
int m = scanner2.nextInt();
if (ffa1){
System.out.println(“结果是”+add(n,m));
}else if(ffa2){
System.out.println(“结果是”+jian(n,m));
}else if(ffa==3){
System.out.println("结果是"+ cheng(n,m));
}else if(ffa==4){
System.out.println("结果是"+chu(n,m));
}else {
System.out.println("不属于");
}
}
}
public static int add(int n,int m){
return n+m;
}
public static int jian(int n,int m){
return n-m;
}
public static int cheng(int n,int m){
return n*m;
}
public static double chu(int n,int m){
return (double) n/m; //除法运算
}