IT 210 Week 4-Checkpoint - Iteration Control Structure

IT 210 Week 4-Checkpoint - Iteration Control Structure -...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
IT/210 Iteration Control Structure Checkpoint Design  a program that models the worm’s behavior in the following scenario:   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.
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Main Module Declare InitDistance as real Declare WormLength as real Write, "Please enter the initial distance between the worm and the apple:" Input InitDistance Write, "Enter the worm's length" Input WormLength Set Distance = InitDistance While (Distance >= WormLength) Write, "The distance is" Distance Set Distance = Distance - WormLength End loop Write, "The last distance before entering apple is: " Distance End Main Module...
View Full Document

Ask a homework question - tutors are online