Analysis
Process:
1. Display welcome screen
2. Prompt for worm’s length
3. Prompt for the beginning distance between the worm and the apple.
4. Calculate the distance between the worm and the apple by the worm’s length till the worm can enter the apple.
Input Worm’s Length (real: wormsLength) Beginning Distance (real: startDistance)
Output
Incremental distance between the worm and apple Distance (real)
Main Module
Begin Main Module:
Declare startDistance as real
Declare wormLength as real
Write, “The journey begins.”
Call User Input Module
Call Distance to apple calculations Module
End Main Module
User Input Module
Begin User Input Module
Write, “How long is this worm?”
Input wormLength
Write, “How far away is the worm from the apple?”
Input startDistance
End User Input Module
Distance to apple calculations Module
Begin Distance to Apple Calculations Module
If (wormLength > 0 And startDistance > 0) Then While (startDistance > 0) Set Distance = startDistance – wormLength End While End Then
End If Write, “Good job the worm made it to the apple!” End Distance to Apple Calculations Module
Iteration Control Structure
Analysis
Process:
1. Display welcome screen
2. Prompt for worm’s length
3. Prompt for the beginning distance between the worm and the apple.
4. Calculate the distance between the worm and the apple by the worm’s length till the worm can enter the apple.
Input Worm’s Length (real: wormsLength) Beginning Distance (real: startDistance)
Output
Incremental distance between the worm and apple Distance (real)
Main Module
Begin Main Module:
Declare startDistance as real
Declare wormLength as real
Write, “The journey begins.”
Call User Input Module
Call Distance to apple calculations Module
End Main Module
User Input Module
Begin User Input Module
Write, “How long is this