Question: Part 2 : Roach.java Implement a class Roach that simulates the growth of a roach population. The constructor takes the size of the initial roach

Part 2: Roach.java
Implement a class Roach that simulates the growth of a roach population.
The constructor takes the size of the initial roach population.
The breed method simulates a period in which the roaches breed, which doubles their population.
The spray(double percent) method simulates spraying with insecticide, which reduces the population by the given percentage.
The getRoaches method returns the current number of roaches.
A testing program called RoachSimulation simulates a population that starts out with 1000 roaches.
Breed, spray to reduce the population by 15 percent, and print the roach count.
Repeat three more times.
 Part 2: Roach.java Implement a class Roach that simulates the growth

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!