Access over 20 million homework & study documents

IT210 - Week 4 Iteration Control Structure

Content type
User Generated
Type
Homework
Rating
Showing Page:
1/1
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.
Main Module
Declare InitialDistance as real
Declare WormLength as real
Write, "Enter initial distance between worm and the apple:"
Input InitialDistance
Write, "Enter the worm's length"
Input WormLength
Set Distance = InitialDistance
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

Sign up to view the full document!

lock_open Sign Up
Unformatted Attachment Preview
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. Main?Module? Declare?InitialDistance?a ...
Purchase document to see full attachment
User generated content is uploaded by users for the purposes of learning and should be used following Studypool's honor code & terms of service.

Anonymous
Just the thing I needed, saved me a lot of time.

Studypool
4.7
Trustpilot
4.5
Sitejabber
4.4

Similar Documents