A worm is moving toward an apple. Each time it moves, the worm cuts the distance between itself and the apple 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.
-------------------------------------------------
I think I rewrote this about 7 times. haha
Worm decreases distance to apple every move by 1 worm length
Loop until worm length is <= 1 worm length from apple
When the worm moves to <=1 worm length enter apple
Process
Get worm length
Get distance from apple
Calculate distance (movement)
Output result
Input
Length of worm (from keyboard)
Distance from apple
Output
Worm length * 1when Distance < Worm length
Write “Worm has entered apple!”
End
Main Module
Declare, Inches, WormLength, DistanceRemaining As Real
Call Welcome Message module
Call Input Data module
Call Calculations module
Write “Nom Nom”
End
Process
Display program title
Display directions
Get worm length
Get distance from apple
Calculate distance (movement)
Output result
Input
Length of worm (from keyboard)
Distance from apple
Output
Worm length * 1.5 when Distance < Worm length
Write “Worm has entered apple!”
End
Program
Declare, Inches, wormLength, DistanceRemaining As Real
Set wormLength = 1 Inch
DistanceRemaining = Inches
If DistanceRemaining <= wormLength
Then Enter
Otherwise
Repeat wormLength = 1.5 * wormLength
Return to wormLength
Enter Apple
Eat Apple
End