473,396 Members | 1,756 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

could use help on a simple problem

I am taking a beginners class in programming and I am very lost. I need
to 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. I now I need to
use an iteration control structure but have no idea where to start or
what to do in this one. Can some one help?

Aug 16 '06 #1
2 5703
"porky008" writes:
>I am taking a beginners class in programming and I am very lost. I need
to 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. I now I need to
use an iteration control structure but have no idea where to start or
what to do in this one. Can some one help?
You could use either a for loop or a while loop here, but since you are
having problems in this area, a while loop is perhaps easier to understand.
Everything is out in plain sight and nothing "under the covers", you might
say. Besides its easier to write pseudocode for a while loop. How about
translating this to C?

while distance>= worm length
distance = distance - worm length

Where distance is the distance remaining to the apple.
Aug 16 '06 #2

porky008 wrote:
I am taking a beginners class in programming and I am very lost. I need
to 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. I now I need to
use an iteration control structure but have no idea where to start or
what to do in this one. Can some one help?
Start by breaking your problem down into smaller problems, eg, write
down with pencil and paper "Move worm:"
position = position + 1

etc

Then translate it into the language you are using.

Aug 16 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Phil | last post by:
Hi There. Seriously stuck and need help! I am trying to access Access 2000 database using ASP.NET(VB) and I am getting a "Could not find installable ISAM" crap. There are quite a few resources...
5
by: Skylar Challand | last post by:
I am getting the following message on a Windows XP computer when trying to run a VB program. The same program is installed on 8 different computers without any issues. .NET Framework is installed &...
2
by: BryanEverly | last post by:
Hi, I'm struggling with a problem and was hoping that someone on this group could point me in the right direction. I'm not looking for a free ride, just a suggestion as to how best to use all...
8
by: Rene | last post by:
Hi, I'm spend many hour to fix this problem, read many articles about it but no article gave a solution. To isolate the problem I've created in IIS6 (WServer2003) a virtual directory test to...
1
by: Pablo | last post by:
Hi, there, I have a simple MS ACCESS application. It supposes to print one report. It works fine in my computer, it also works fine in some other computers, but it stops working in one of the...
3
by: Lei Jiang | last post by:
If I have to add __gc in every class, it would be a huge work. Is there any option that could compile all C++ class into manganged class without modify any source code?
5
by: Paul Smith | last post by:
I am hoping this is a simple problem for someone. We have two development servers, DEVNET (a web server) and DEVSQL (a DB / File Server). We have recently moved all of our .NET source code from...
18
by: Sender | last post by:
Yesterday there was a very long thread on this query. (You can search on this by post by 'sender' with subject 'Simple Problem' post date Oct 7 time 1:43p) And in the end the following code was...
2
by: antonyliu2002 | last post by:
I am testing AJAX. I've downloaded the AJAX Extension and the CTP December package and installed on BOTH my development machine and the production server. Then I created a very very simple web...
2
by: kamiseq | last post by:
i have phpunit installed as on the site(http://www.phpunit.de/ pocket_guide/3.2/en/installation.html). im running simple tests (that actually have been running on sqlite base) and I got that...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.