/**
 * DeerPopulationCalculator.java
 * Sample program to introduce java constructs.
 * Fictional Deer Population Calculator
 *
 * @author <Replace by your name>
 */

public class DeerPopulationCalculator {
 private final int CURRENT_YEAR = 2011;

 private final int CURRENT_POPULATION = 10000;
 private final int DOE_PERCENT = 70;
 private final int AVERAGE_NO_FAWNS = 2;

 /* Include more detailed statistics */
 /* Death Rate, as a percent of last years population */
 private final int DEATH_RATE_PERCENT = 10;

 /*
  * If population goes beyond supported population, it will start falling by
  * 20% (Population Fall Rate) till it goes below the supported population.
  * All other statistics(like death rate) are ignored when this happens.
  */
 private final int MAX_POPULATION_SUPPORTED =  40000;
 private final int POPULATION_FALL_RATE = 20;

 /*
  * Method to calculate and print population for the next 300 years
  */
 private void calculate() {
  int population = CURRENT_POPULATION;
  System.out.println("Starting population  = " + population);
  /* Print for the next 300 years */
  for (int i = 1; i <= 300; i++) {
   int year = CURRENT_YEAR + i;
   /* Check if population has exceeded maximum */
   if (population > MAX_POPULATION_SUPPORTED) {
    population = population - (population * POPULATION_FALL_RATE)/ 100;
   } else {

    int noOfDoes = (population * DOE_PERCENT) / 100;
    int noOfFawns = (noOfDoes * AVERAGE_NO_FAWNS);
    int noOfDeaths = (population * DEATH_RATE_PERCENT) / 100;
    population = population + noOfFawns - noOfDeaths;

   }
   System.out.println("Population for year " + year + " = "
     + population);
  }

 }

 public static void main(String args[]) {
  DeerPopulationCalculator recit = new DeerPopulationCalculator();
  recit.calculate();
 }
}
