Trace a decision — quick review
A library desk has a rule for late books, invented for this lesson.
At a selection step, work out the condition with the current values each time the step is reached. If it is true, carry out the action the step gives for true. If it is false, carry out the step's otherwise action when it has one. After either, follow any instruction about where to go next, and continue with the next step in order when there is none. The condition decides which action is carried out.
Draw a table with a column for the step, a column for the condition with its values filled in and a column for what the procedure holds after the step.
Write the input above the table.
Carry out the steps in order. At a selection step, copy the condition with the real values in place of the names.
Write true or false beside the condition. If it is true, do the action the step gives for true. If it is false, do the step's otherwise action when it has one. After either, follow any instruction about where to go next, and move to the next step in order when there is none.
Stop at the step that says stop. The output is what that step announces.
Trace again with inputs that take the other paths: one input that makes each selection step's action run, and one for which no condition is true. For the late-fee procedure,
0,3and8days late do that.
Do not skip a step because the answer seems clear. Carry out every step the procedure reaches, including the ones whose condition is false.
The opposite slip is carrying out an action whose condition was false, or going on to step 3 after step 2 has said go to step 5. For 0 days late that slip announces 1 coin where the rule gives 0. Sequencing means carrying out the steps in the order the procedure gives them. Follow each jump as written.