Computer Science Homework Solutions
Problem
#95552

Create a program that models a worm’s behavior

Create 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.

Attached file(s):
Attachments
Iteration Control Structure.doc  View File

Attachment Content Summary (Note: view attachment at the above link before purchasing. Actual attachment content may vary slightly from that shown below.)

Iteration Control Structure.doc
Iteration Control Structure

Create 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.

Solution Summary

Please look into the attached word doc. Although, no objective is given the statement reveals that the final goal of the worm is the enter the apple. Furthermore, there is nothing stopping it from doing so (predators, impediments, stamina, etc). So, it is always true that the worm enters the apple. The question then is when? The following program attempts to answer the question by finding the integral number of moves needed to get the worm close to the apple within its body length.
The program has been extensively commented and can be implemented in any programming language easily. Hope it helps.

Solution
What is this?
By OTA - Overall OTA Rating
Purchase Cost Now
$2.19 CAD (was ~$31.92)
Included in Download
  • Plain text response
  • Attached file(s):
    • Iteration+Control+Structure.doc
$2.19 Instant Download
Add to Cart
Why you can trust BrainMass.com
  • Your Information is Secure
  • Best Online Academic Help Service
  • Students find real academic Success
Related Solutions
  • ITPM - Is project planning needed in an Extreme Programming (XP) project? Why or why not? A good tutorial outlining XP will be found at: www.extremeprogramming.org . 2 to 3 pages with reference.
  • Define the follow types of statement used in computer programming and how you would utilize them in your program. - DQ #3 Define the follow types of statement used in computer programming and how you would utilize them in your programs? I/O (input/output) Calculation (equations) selection (conditional) repetit ...
  • Programming Concept: Arrays, Iterative Structures, Loop - Why are there so many iterative structures and what is the purpose of each. Think about looping and why different ones exist and why you can't have just one. What is an array and why are they imp ...
  • Benefits of programming knowledge - How does knowledge of programming concepts benefits individuals working in almost any IT position? Include at least one specific example of how java programming knowledge benefits nonprogramming worki ...
  • Programming - Should there be a single programming language for all programming domains? Explain why or why not.
Browse