{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Iteration Control Structure

Iteration Control Structure - Write “Enter the distance...

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

View Full Document Right Arrow Icon
Iteration Control Structure 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: Write “Enter the distance from the apple” Input Number As Distance Write “Enter the length of the worm” Input Number As Length While distance > Length Calculate Distance = Distance – Length Until Distance <= Length End While Write “The worm has reached the apple” End...
View Full Document

{[ snackBarMessage ]}