
6.3 Event-Controlled Looping 283
Using a while loop construct, the pseudocode for the cashier would look
like this:
set total to $0.00
reach for first item
while item is not the divider bar
{
add price to total
reach for next item
}
// if we get here, the item is the divider bar
output the total price
It is also possible to construct a while loop whose condition never evaluates
to false. That results in an endless loop, also known as an infinite loop.
Because the condition always evaluates to true, the loop body is executed
repeatedly, without end. This might happen if items other than the divider
bar were placed continuously on the conveyor belt. One sy