W4 CheckPoint Iteration control structure

W4 CheckPoint Iteration control structure - Display Enter...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
W4 Checkpoint: Iteration Control Structure Analysis Process : Cut the distance between the worm and the apple by the worm's body length until the worm is close enough to enter the apple. Input: Initial distance of worm from the apple (real: Initial Distance) Length of the worm (real: Worm Length) Output: Incremental distance between worm and apple (real: Distance) Final distance between worm and the apple Design Main Module Declare Initial Distance as real Declare Worm Length as real Display "Enter initial distance between worm and the apple:" Input Initial Distance
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Display Enter the worm's length" Input Worm Length //cut the distance between the worm and apple by the worm's body length //until the worm is close enough to enter the apple Set Distance = Initial Distance While (Distance >= Worm Length) //loops until worm is within body length of apple Display "The distance is" Distance Set Distance = Distance - Worm Length End loop //print final distance before entering the apple Display "The last distance before entering apple is: " Distance End Main Module...
View Full Document

Page1 / 2

W4 CheckPoint Iteration control structure - Display Enter...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online