How many decisions does it take to hit a ping-pong ball?
Very many. 10s of thousands; maybe more.
The answer may surprise you.
However,
controlling a ping-pong paddle
and coordinating it with a moving ball
is very difficult.
Scientists have written a computer program
for a ping-pong playing robot.
The program constantly makes
very complicated decisions involving many
thousands of IFs and other control structures.
We won't write programs quite that complicated here.
An airline company has a three level price policy:
Here is a start on the program that calculates airfare:
PRINT "Enter full fare" INPUT FARE PRINT "Enter age" INPUT AGE ' 'Calculate discount rate based on age . . . . 'Calculate and print the fare PRINT "Your fare is:", FARE * RATE END
RATE will be one of three values:
0.0, 0.70, or 1.00 based on AGE.
What type of control structure can you use to make this choice?