Java Reference
In-Depth Information
Be sure to use classes Pile , Player , and Game in your
implementation. A player can be either stupid, smart, or human. (Human
Player objects prompt for input.)
ANSWERS TO SELF-CHECK QUESTIONS
1. Never
2. The waitForBalance method would never return due to an infinite loop
3.
int i = 1;
while (i <= n)
{
double interest = balance * rate / 100;
balance = balance + interest;
i++;
}
4. 11 times
5. Change the inner loop to for (int j = 1; j <= width; j++)
6. 20
7. Because we don't know whether the next input is a number or the letter Q
8. No. If all input values are negative, the maximum is also negative.
However, the maximum field is initialized with 0. With this simplification,
the maximum would be falsely computed as 0
9. int n = generator.nextInt(2); // 0 = heads, 1 = tails
10. The program repeatedly calls Math.toRadians(angle) . You could
simply call Math.toRadians(180) to compute ƚ.
11. You should step over it because you are not interested in debugging the
internals of the println method.
12. You should set a breakpoint. Stepping through loops can be tedious.
Search WWH ::




Custom Search