Here is the problemDesign 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 distanceapple.
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
Here is my working solution. This is not an exercise in writing a program in a specfic language, but an exercise in how to write a program.
declare Wormlength, AppleDistance as real
write what is the length of the worm?
write What is the distance to the apple?
While AppleDistance > Wormlength
AppleDistance - Wormlength
This is where I start running into problems. I know I need some kind of loop function and I need away to keep track of the distance covered.
Any help or direction would be great.