cocowyx
幼苗
共回答了23个问题采纳率:78.3% 举报
给你个例子,手写的,没测试1.public Compu(int a, int b)
public Compu(int a)
2.假设你要求出所有四则运算的值int[] calulate(int a, int b) {
int[] result = new int[4];
result[0] = a+b;
result[1] = a-b;
result[2] = a*b;
try {
result[3] = a/b;
} catch (ArithmeticException e) {
if (b == 0) System.err.println("除数为0");
else e.printStackTrace();
}
return result;
}
double sqrt(int a) {
return Math.sqrt(Double.parseDouble(String.valueOf(a)));
}
1年前
4