i want to ask a question about a class i found on a book
my problem is in projectedPopula tion method. I want to ask why we use the count and populationAmoun t variable .I mean where is the problem if i use years and population variables?
thanks !
my problem is in projectedPopula tion method. I want to ask why we use the count and populationAmoun t variable .I mean where is the problem if i use years and population variables?
thanks !
Code:
public class Species { private String name; private int population; private double growthRate; public void readInput() { // ................................ System.out.println("What is the species's name?"); name = keyboard.nextLine(); //more code population = keyboard.nextInt(); System.out.println("Enter growth rate (percent increase per year)"); growthRate = keyboard.nextDouble(); } public void writeOutput() { System.out.println("Name = " + name); System.out.println("Population = " + population); System.out.println("Growth rate = " + growthRate + "%"); } public int projectedPopulation(int years) { double populationAmount = population; int count = years; while((count > 0) && (population > 0)) { populationAmount = (populationAmount + (growthRate/100)*populationAmount); count--; } if (populationAmount > 0) return (int)populationAmount; else return 0; };
Comment