
February 10th, 2013, 02:19 AM
|
|
Registered User
|
|
Join Date: Feb 2013
Location: South Florida
Posts: 3
Time spent in forums: 36 m 25 sec
Reputation Power: 0
|
|
|
Homework - Population Projection
Hello All,
I have been asked to make a program that will calculate a the population over the next 5 years.
I have been trying to get this but it seems I am off by one each year as the calculation goes.
Can someone point me in the right direction of what I am doing wrong? I tried to adjust the datatype but was not able to get a better answer.
My answer I am getting is
314812582
317592678
320372774
323152870
325932966
Code:
public class Population
{ public static void main(String[] args)
{
int currentPopulation = 312032486;
int secondsInYear = 60 * 60 * 24 * 365;
int birthsPerYear = secondsInYear / 7;
int deathsPerYear = secondsInYear / 13;
int immigrantPerYear = secondsInYear / 45;
int perYearAdditions = birthsPerYear - deathsPerYear + immigrantPerYear;
int yearOnePopulation = currentPopulation + perYearAdditions;
System.out.println(yearOnePopulation);
System.out.println(yearOnePopulation + perYearAdditions);
System.out.println(yearOnePopulation + (perYearAdditions * 2));
System.out.println(yearOnePopulation + (perYearAdditions * 3));
System.out.println(yearOnePopulation + (perYearAdditions * 4));
}
}
thanks
Jerry
|