Purchase Solution

Create a Program that Models a Worm's Behavior

Not what you're looking for?

Ask Custom Question

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.

Purchase this Solution

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 Preview

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

Purchase this Solution


Free BrainMass Quizzes
Java loops

This quiz checks your knowledge of for and while loops in Java. For and while loops are essential building blocks for all Java programs. Having a solid understanding of these constructs is critical for success in programming Java.

Word 2010: Table of Contents

Ever wondered where a Table of Contents in a Word document comes from? Maybe you need a refresher on the topic? This quiz will remind you of the keywords and options used when working with a T.O.C. in Word 2010.

Excel Introductory Quiz

This quiz tests your knowledge of basics of MS-Excel.

Basic UNIX commands

Use this quiz to check your knowledge of a few common UNIX commands. The quiz covers some of the most essential UNIX commands and their basic usage. If you can pass this quiz then you are clearly on your way to becoming an effective UNIX command line user.

Javscript Basics

Quiz on basics of javascript programming language.