Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write C++ program: A local government organization has been testing a new biological triggering device. The actual cost has gotten out of hand and they

Write C++ program: A local government organization has been testing a new biological triggering device. The actual cost has gotten out of hand and they have recruited you to test the new style trigger through simulation. How does the trigger work?

The trigger device is a 20 by 20 grid where each square is a sensor. Each square in the grid starts with one flea. (The flea is the biological part) All the fleas jump at the same time and land on a neighboring square or the current square. So some squares now have more than one flea and other squares blank or without a flea. The fleas continue to jump and at some point when 83% of the squares are blank (no fleas) the trigger is fired. If the flea jumps off the 20 x 20 grid, the flea is zapped and will no longer be able to jump.

Using actual fleas and the termination of the fleas during testing became the big cost over run the government was having to deal with. Zapping electronic fleas is cheaper than real fleas.

Now to simulate this process, we need to know which way a given flea will jump. A flea will only jump to a neighboring square and never two or more squares over. (These fleas are breed with shorter legs so they cant jump as far.) Now after much research, it was determine which direction a flea will jump. There are nine places/squares a flea can land, the neighboring square or the square the flea is currently jumping from. A flea will jump in one of the corner squares 5% of the time. Each corner is 5%. The top, bottom, left and the current square the flea will jump in 15% of the time and to the right 20% of the time. 20% direction is the way the dogs hair grows and the fleas jump with the hair a little more often than in the other directions. A flea is in the middle square and the directions the flea will jump are shown below.

5 15 5

15 15 20

5 15 5

A simulation consists of setting one flea on each square then letting each flea jump. After each jumps check to see if 83% of the squares are empty. If they are not, then let each flea jump again. You continue letting the fleas jump until 83% of the squares are empty and the simulation stops, ie the bomb is detonated. Now since jumping is random movements, running one simulation will not be enough information needed to accomplish this task. You will need to run the simulation again and again to get an average. You will need to run the simulation 2500 times and then compute the following resulting values.

Inputs:None

Outputs:

1. How many times will the fleas jump before the trigger is fired?

2. If fleas jumps 4 times every 7 seconds, determine how much time does one have to clear the area before the trigger is fired?

3. What is the shortest time and the longest time you computed, given all simulations, which was needed to clear the area?

4. How many fleas on the average were lost before the trigger was fired? (This is to show the government the cost savings for using simulation rather than using real fleas in a simulation.)

Restrictions:Use 2-d arrays(2). Run the simulation 2500 times to generate the results.

Output: Format output in a readable style. Output the results in the file.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Security

Authors: Alfred Basta, Melissa Zgola

1st Edition

1435453905, 978-1435453906

Students also viewed these Databases questions

Question

Define span of management or define span of control ?

Answered: 1 week ago

Question

What is meant by formal organisation ?

Answered: 1 week ago

Question

What is meant by staff authority ?

Answered: 1 week ago

Question

Discuss the various types of policies ?

Answered: 1 week ago