
280 CHAPTER 6 Flow of Control,Part 2: Looping
Introduction
Have you ever watched the cashier at the grocery store? Let’s call the cashier
Jane. Jane’s job is to determine the total cost of a grocery purchase. To
begin, Jane starts with a total cost of $0.00. She then reaches for the first
item and scans it to record its price, which is added to the total. Then she
reaches for the second item, scans that item to record its price, which is
added to the total, and so on. Jane continues scanning each item, one at a
time, until there are no more items to scan. Usually, the end of an order is
signaled by a divider bar laying across the conveyor belt. When ...