MCS-170 The Nature of Computer Science

Alice Lecture 3


1. Program Control Structures - Sequencing, Conditionals, Loops

(new code)

If penguin is within 2 meters of shark
Do the following steps in order
penguin rises into the air to the height of the palm tree
penguin moves to the top of the palm tree
Else
Do nothing
shark swims to palm tree
Loop 4 times
Do the following steps in order
shark moves toward the palm tree
shark turns 180 degrees
shark moves away from the palm tree
shark turns 180 degrees