
330 CHAPTER 6 Flow of Control,Part 2: Looping
DISCUSSION QUESTIONS
1. What is the sentinel value of your while loop?
2. Explain the purpose of the priming read.
?
Thus, you would get an item, then get its price using code like the
following:
Item newItem;
double price;
newItem = getNext( );
price = newItem.getPrice( );
■
After adding the price of an item to your subtotal, call the animate
method of the Cashier class. This method will display both your
subtotal and the correct subtotal so that you can verify that your
code is correct.
The animate method has the following API:
void animate( double subtotal )
Thus, if your variable representing the current total ...