W4 CheckPoint Iteration control structure

W4 CheckPoint Iteration control structure - Display...

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...

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