Worm It210

Only available on StudyMode
  • Download(s) : 25
  • Published : April 24, 2011
Open Document
Text Preview
Week 4 continues structured programming and will cover iteration control structures and designing complex algorithms using the three basic control structures. A worm is moving toward an apple. Each time it moves, the worm cuts the distance between itself and the apply by its own body length until the worm is close enough to enter the apple. The worm can enter the apple when it is within a body length of the apple.

Main
Declare Length as real
Declare Distance as real
Call Get Length
Call Get Distance
Call Move Worm
End

Get Length Write “Enter the length of the worm"
Write Get Length
End Get Length

Get Distance
Write "Enter the distance to get to apple"
Get Distance
Get Distance

Move Worm
While Distance > 0
Distance = Distance - Length
End While
Write “Worm has reached the apple."
End Move Worm

A worm is moving toward an apple. Each time it moves, the worm cuts the distance between itself and the apply by its own body length until the worm is close enough to enter the apple. The worm can enterA worm is moving toward an apple. Each time it moves, the worm cuts the distance between itself and the apply by its own body length until the worm is close enough to enter the apple. The worm can enter the apple when it is within a body length of the apple. the apple when it is within a body length of the apple.A worm is moving toward an apple. Each time it moves, the worm cuts the distance between itself and the apply by its own body length until the worm is close enough to enter the apple. The worm can enter the apple when it is within a body length of the apple.
tracking img