-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPopulationProjection.java
More file actions
36 lines (33 loc) · 1.41 KB
/
PopulationProjection.java
File metadata and controls
36 lines (33 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/*
Rahim Siddiq
Apr 13 2023
Population Projection
*/
public class PopulationProjection
{
public static void main(String[] args)
{
// Variables for current population and number of seconds in a year
int currentPopulation = 312032486;
// Variables and calculations for births, deaths, and immigration. Data derived from Census
int secondsPerYear = 365 * 24 * 60 * 60;
double births = secondsPerYear / 7.0;
double deaths = secondsPerYear / 13.0;
double immigrants = secondsPerYear / 45.0;
// Title of program and description of program function to user
System.out.println();
System.out.println(" ================================================================");
System.out.println(" ===================== POPULATION PROJECTION ====================");
System.out.println(" ================================================================");
System.out.println(" Program uses the U.S. Census Bureau's formula to display");
System.out.println(" population projections over 5 years starting from 312,032,486");
System.out.println(" ----------------------------------------------------------------");
System.out.println();
// Loop to perform projections over each of the next 5 years and output data to user
for (int year = 1; year <= 5; year++)
{
currentPopulation += births - deaths + immigrants;
System.out.println(" Year " + year + " population: " + currentPopulation);
}
}
}