In: Computer Science
Code in java(eclipse) and please use simple codes
Assignment
Bigfoot has reportedly been seen in Southeast Texas forests. We have a drone searching for Bigfoot that can take pictures from the air. During a 24-hour period the drone can fly over the forest 3 times. On each flight we estimate Bigfoot will be in range of the camera on the drone for 2 minutes. The camera can take 10 photos per minute. We estimate there is a 30% chance Bigfoot will appear on each photo taken.
Run a simulation of our drone taking photos of Bigfoot. For each picture taken, generate a random number from 0-100 and compare it to the percentage chance Bigfoot will appear in the photo. Calculate the number of photos taken during the 24-hour period and print it. Calculate the number of photos taken during 24-hour period in which Bigfoot appears in the photo and print that also.
Run the above simulation 5 times. At the end, compute the average number of photos taken (rounded down) during a 24-hour period in which Bigfoot appears (by averaging the number of photos taken of Bigfoot during all of the 5 simulations).
Run your program. Your program must run successfully to receive full credit for this homework. Take a screenshot of your program. The screenshot should show all of your source code and the output of your program in the Console window. Resize the editor and/or console windows as needed so that everything is shown. You may also need to expand Eclipse to full screen size. If you program is too large you can take multiple screenshots so the source code is all shown and zip all the files together (use .zip format only, not .7zip, .rar or any other format besides .zip).
An example of output from the program might look something like:
Simulation 1: Photos of Bigfoot: 33 of 60
Simulation 2: Photos of Bigfoot: 37 of 60
Simulation 3: Photos of Bigfoot: 49 of 60
Simulation 4: Photos of Bigfoot: 40 of 60
Simulation 5: Photos of Bigfoot: 51 of 60
Average photos taken of Bigfoot: 42 of 60
Here is the completed code for this problem. Comments are included, go through it, learn how things work and let me know if you have any doubts or if you need anything to change. If you are satisfied with the solution, please rate the answer. Thanks
// BigfootSimulation.java
import java.util.Random;
public class BigfootSimulation {
public static void main(String[] args) {
//random number generator
Random random = new Random();
//number of times the drone move across the forest in 24 hrs
int num_times = 3;
//number of minutes the bigfoot is in range
int in_range = 2;
//number of photos taken in a minute
int photos_per_minute = 10;
//percentage of a chance of bigfoot in each photo
int chance = 30;
//number of simulations
int num_simulations = 5;
//finding number of photos in each simulation
int num_photos_per_simulation=num_times*in_range*photos_per_minute;
//total of all bigfoot found (to find average)
int sum = 0;
//looping through each simulation
for (int i = 1; i <= num_simulations; i++) {
//initializing number of findings to 0
int found = 0;
//looping for num_photos_per_simulation time
for (int j = 0; j < num_photos_per_simulation; j++) {
//generating a random value between 0 and 99
int percentage = random.nextInt(100);
//if this is under chance, incrementing found
if (percentage < chance) {
found++;
}
}
//displaying number of findings in this simulation
System.out.println("Simulation " + i + ": Photos of Bigfoot: "
+ found + " of " + num_photos_per_simulation);
//adding to sum
sum += found;
}
//finding average and displaying it
int average = (int) Math.round((double) sum / num_simulations);
System.out.println("Average photos taken of Bigfoot: "
+ average + " of " + num_photos_per_simulation);
}
}
/*OUTPUT*/
Simulation 1: Photos of Bigfoot: 20 of 60
Simulation 2: Photos of Bigfoot: 20 of 60
Simulation 3: Photos of Bigfoot: 17 of 60
Simulation 4: Photos of Bigfoot: 20 of 60
Simulation 5: Photos of Bigfoot: 17 of 60
Average photos taken of Bigfoot: 19 of 60