The class RoachPopulation 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 roaches breed, which doubles their population.The spray method simulates spraying with insecticide, which reduces the population by 10%.The getRoaches method returns the current number of roaches.A program called, RoachSimulation simulates a population that starts out with a specific number of roaches. Breed, spray and print the roach count. Repeat three more times. Sample output:Enter the number of roaches in the population25Creating the Roach PopulationThe initial size of the population is 25Breeding and SprayingAfter breeding and spraying 1 times the roach count is 45Breeding and SprayingAfter breeding and spraying 2 times the roach count is 81Breeding and SprayingAfter breeding and spraying 3 times the roach count is 146Breeding and SprayingAfter breeding and spraying 4 times the roach count is 263 Include the following for the xxx_RoachPopulation class:1. The instance variable of the class, RoachPopulation2. Include 2 constructors: No-arg and one that accepts the initial size of the population3. Add getters and setters for instance variables4. Include the breed and spray methods Include the following for the xxx_RoachSimulation class:1. A main method which creates the RoachPopulation object, calls all the requiredmethods and prints the output.2. A Scanner object must be used.3. The class should work for all values entered by the user.4. The output should look like the sample output above.Please note the following requirements  Two classes submitted and named as required: xxx_RoachPopulation andxxx_RoachSimulation A comment at the start or the program describing what the program does  Coding style: All code must be indented for readability and consist of only one statement per line. Naming conventions followed for variables and methods  RoachPopulation class: o Instance variable o Constructors o Getter o Setter o breed methodo spray method   RoachSimulation class:o Scanner object o Prompt to user and getting value o RoachPopulation object created o Loop used to breed, spray and print message o Methods breed and spray called correctly o Output matches sample output in format

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

The class RoachPopulation 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 roaches breed, which doubles their population.
The spray method simulates spraying with insecticide, which reduces the population by 10%.
The getRoaches method returns the current number of roaches.
A program called, RoachSimulation simulates a population that starts out with a specific number of roaches. Breed, spray and print the roach count. Repeat three more times.

Sample output:
Enter the number of roaches in the population
25
Creating the Roach Population
The initial size of the population is 25
Breeding and Spraying
After breeding and spraying 1 times the roach count is 45
Breeding and Spraying
After breeding and spraying 2 times the roach count is 81
Breeding and Spraying
After breeding and spraying 3 times the roach count is 146
Breeding and Spraying
After breeding and spraying 4 times the roach count is 263

Include the following for the xxx_RoachPopulation class:
1. The instance variable of the class, RoachPopulation
2. Include 2 constructors: No-arg and one that accepts the initial size of the population
3. Add getters and setters for instance variables
4. Include the breed and spray methods

Include the following for the xxx_RoachSimulation class:
1. A main method which creates the RoachPopulation object, calls all the required
methods and prints the output.
2. A Scanner object must be used.
3. The class should work for all values entered by the user.
4. The output should look like the sample output above.

Please note the following requirements 
 Two classes submitted and named as required: xxx_RoachPopulation and
xxx_RoachSimulation
 A comment at the start or the program describing what the program does 
 Coding style: All code must be indented for readability and consist of only one statement per line. Naming conventions followed for variables and methods 
 RoachPopulation class: 
o Instance variable 
o Constructors 
o Getter 
o Setter 
o breed method
o spray method 

 RoachSimulation class:
o Scanner object 
o Prompt to user and getting value 
o RoachPopulation object created 
o Loop used to breed, spray and print message 
o Methods breed and spray called correctly 
o Output matches sample output in format 

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 5 steps with 5 images

Blurred answer
Knowledge Booster
Unreferenced Objects
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education