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 : 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 spraydouble 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 roaches.
Breed, spray to reduce the population by percent, and print the roach count.
Repeat three more times.
Without using if statements.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
