Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

use eclipse CPS 2231 Computer Organization and Programming Progra Due Date: As noted on Blackboard Concepts: Classes and Objects Point value: 100 points The class

image text in transcribed

image text in transcribed

use eclipse

CPS 2231 Computer Organization and Programming Progra Due Date: As noted on Blackboard Concepts: Classes and Objects Point value: 100 points 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 methad 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. The program repeats the steps: Breed, Spray and Print the roach count, 4 counts. 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 1. The program will consist of two classes: xxxx RoachPopulation and xxxx_ RoachSimulation. 2. The xxxx RoachPopulation class consists of the following: a. An instance variable, populationSize, which is the number of roaches in the population b. Include 2 constructors: No-arg and one that accepts the initial size of the population as a parameter c. An accessor, getPopulationSize() which returns the population size. d. A mutator, setPopulationSize(int size) which updates the population size e. A breed() method. The breed method doubles the value of the populationSize f. A spray() method. The spray method reduces the value of the populationSize g. Note that the xxxx RoachPopulation class does not print any messages instance variable when it runs instance variable by 10% when it runs. All printing is done in the RoachSimulation

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Driven Web Sites

Authors: Joline Morrison, Mike Morrison

2nd Edition

? 061906448X, 978-0619064488

More Books

Students also viewed these Databases questions

Question

-How does collectability affect revenue recognition?

Answered: 1 week ago