JAVA 测试题目 求大神帮我忙 非常感谢
1个回答

给你个例子,手写的,没测试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)));

}