# Thread: help with a programing problem

1. Here is the problem
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.

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.

input module

declare Wormlength, AppleDistance as real

write what is the length of the worm?
input WormLength

write What is the distance to the apple?
input AppleDistance

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.

2. ** REGISTER to REMOVE This Ad On The Site!! **
3. What are you trying to find out? The number of steps?

4. no I need to designa program that models the worm’s behavior in the given scenario.

5. input module

declare Penislength, VaginaDistance, ThrustCount as real

write what is the length of the penis?
input PenisLength

write What is the distance to the vagina?

Set ThrustCount = 0

Increase ThrustCount by 1
end while

Call Process EnterVagina

6. I contend that ThrustCount will = 0 until penis enters vagina, but I degress. Thanks for the help

7. Couldn't resist changing the variable names, sorry!

8. Originally Posted by Barbarossa
Couldn't resist changing the variable names, sorry!
It was more interesting than apples anyway

9. I have another question relating to the original question. Is the counter actually need for this to work? I think the computer should be able to remember the value of VaginaDistance without the counter I could be wrong. I know I can have loops with and without counters. It seems to me this would be a time were a counter isn't needed. thanks

10. You don't need the counter to model the behaviour of the worm, no. I only put one in because you said you wanted a counter

11. sorry about that... It was a left over thought from tryi ng to solve the problem

Page 1 of 2 12 Last

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•