输出示例:
FIXME:完成getUserNum()
FIXME:完成getUserNum()
FIXME:完成computeAvg()
平均:-1
我拥有的代码:
public class MthdStubsStatistics {
public static int getUserNum() {
System.out.println("FIXME: Finish getUserNum()");
return -1;
}
public static Integer computeAvg(){
System.out.println("FIXME: Finish computeAvg()");
return -1;
}
public static void main() {
int userNum1 = 0;
int userNum2 = 0;
int avgResult = 0;
userNum1 = getUserNum();
userNum2 = getUserNum();
avgResult = computeAvg(userNum1, userNum2);
System.out.println("Avg: " + avgResult);
return;
}
}
我遇到的问题是computeavg方法给我这个错误:
MthdStubsStatistics.java:23: computeAvg() in MthdStubsStatistics cannot be applied to (int,int) avgResult = computeAvg(userNum1, userNum2);
最佳答案
您正在使用参数computeAvg(userNum1,userNum2)调用函数computeAvg。在函数声明中,您需要提供以下参数:
public static Integer computeAvg(int userNum1, int userNum2){
//do something with userNum1 and userNum2 here
System.out.println("FIXME: Finish computeAvg()");
return -1;
}