Write a program to answer questions like the following: Suppose the species Klingon ox has a population

Question:

Write a program to answer questions like the following: Suppose the species Klingon ox has a population of 100 and a growth rate of 15 percent, and it lives in an area of 1500 square miles. How long would it take for the population density to exceed 1 per square mile? Use the class Species in Listing 5.19 with the addition of the getDensity method from Self-Test Question 10.

Listing 5.19

Species name: String population: int growthRate: double + readInput () : void + writeOutput (): void + predictPopulation (int years): int + setSpecies (String newName, int newPopulation, double newGrowthRate): void + getName (): String + getPopulation (): int + getGrowthRate(): double + equals (Species otherObject): boolean


Self-Test Question 10.

Define a method called getDensity that could be added to the definition of the class SpeciesSecondTry in Listing 5.6. This method has one parameter of type double that is named area. The parameter area gives the area occupied by the species, expressed in square miles. The method getDensity returns a value of type double that is equal to the number of individuals per square mile of the species. You can assume that the area is always greater than zero. The definition is very short.

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Question Posted: