. Advertisement .
..3..
. Advertisement .
..4..
Offer me the best recommendation on how to define stubs for the methods called by the below main(). The following command is used:
FIXME: Finish getUserNum()
FIXME: Finish getUserNum()
FIXME: Finish computeAvg()
Avg: -1
import java.util.Scanner;
public class MthdStubsStatistics {
public static int methodName (int userNum1, int userNum2, int computerAvg) {
System.out.println("FIXME: Finish getUserNum()");
System.out.println("FIXME: Finish getUserNum()");
System.out.println("FIXME: Finish computerAvg()");
System.out.println("Avg: -1");
return 0;
}
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;
}
}
I used many ways in another forum, but it did not work. Any solution is much appreciated!
The cause: I think the cause is that your
getUserNum()
method should return a user’s unique ID, but instead you’re defining a stub that simply returns-1
on every invocation.Solution: You should be defining these two methods, as you can see from your main() method:
Hence, describe them. Here is an example of the
getUserNum()
stub.Then leave
computeAvg()
up to the OP.