Question: Implement a class RoachPopulation that simulates the growth of a roach population. The constructor takes the size of the initial roach population. The breed method
Implement a class RoachPopulation 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 pro gram called RoachSimulation simulates a population that starts out with 10 roaches. Breed, spray to reduce the population by 10 percent, and print the roach count. Repeat three more times.
Step by Step Solution
There are 3 Steps involved in it
Sure lets implement the RoachPopulation class in Java java public class RoachPopulation private doub... View full answer
Get step-by-step solutions from verified subject matter experts
