编写程序编写一个计算器,可以实现两个数加减乘除运算

2024-12-16 10:45:58
推荐回答(2个)
回答1:

public class Computer{

public int sum(int a,int b){

int sum = a + b;
return sum;
}

public int minus(int a,int b){

int minus = a - b;
return minus;

}

}
public class TestComputer{

public static void main(String[] args){

Computer c = new Computer();

int sum = c.sum(12,2);

int minus = c.minus(1,4);

System.out.println(sum);
System.out.println(minus);

}

}

回答2:

哪有疑问