
6.2 General Form for while Loops 281
We can see a pattern here. We start with an order total of $0.00. Then we
repeat a set of operations for each item. We reach for the item and check
whether it’s the divider bar. If the item is not the divider bar, we add the item’s
price to the order total. We reach for the next item and check whether it’s the
divider bar, and so on. When we reach for the item and find that it is the
divider bar, we know there are no more items to process, so the total we have
at that time is the total for the whole order. In other words, we don’t know the
number of items that will be placed on the conveyor belt. We just process ...