我正在使用我的第一个Java类,并且在打印出比所需更多的行时出错
所以我假设程序重复而不是退出并转到下一个方法。不确定如何更正此重复,尝试先更改return -1;
而不进行更正。
分配要求“定义下面main()调用的方法的存根。”并打印这4行:
FIXME: Finish getUserNum()
FIXME: Finish getUserNum()
FIXME: Finish computeAvg()
Avg: -1
我打印出来了:
FIXME: Finish getUserNum()
FIXME: Finish getUserNum()
FIXME: Finish getUserNum()
FIXME: Finish getUserNum()
FIXME: Finish computeAvg()
Avg: -1
以下是我的代码注意事项:
import java.util.Scanner;
public class MthdStubsStatistics {
/* Your solution goes here */
public static Integer getUserNum() {
System.out.println("FIXME: Finish getUserNum()");
System.out.println("FIXME: Finish getUserNum()");
return -1;
}
public static Integer computeAvg(int userNum1, int userNum2){
System.out.println("FIXME: Finish computeAvg()");
return -1;
}/* ^ Your solution goes here ^ */
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;
}
}
答案 0 :(得分:-1)
您正在拨打getUserNum
两个电话,并拨打computeAvg
一个电话。