-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExercise02_11.java
More file actions
38 lines (34 loc) · 1.21 KB
/
Exercise02_11.java
File metadata and controls
38 lines (34 loc) · 1.21 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
37
38
package Chapter2;
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
import java.util.Scanner;
/**
*
* @author jorda
*/
public class Exercise02_11 {
public static void main(String[] args){
Scanner input = new Scanner(System.in);
System.out.println("Enter the number of years: ");
int years = input.nextInt();
int currentYear = 0;
double yearlypopgrowth, secinyear, yearlybirths, yearlydeaths, yearlyimm;
int currentpop;
//yearlyimm = number of immagrants every year
//yearly* number of each stat in a year
secinyear = 60 * 60 * 24 * 365;
yearlybirths = secinyear / 7.0;
yearlydeaths = secinyear / 13.0;
yearlyimm = secinyear / 45.0;
yearlypopgrowth = yearlybirths + yearlyimm - yearlydeaths;
currentpop = 312032486;
while (currentYear < years){
currentpop = (int)(yearlypopgrowth + currentpop);
currentYear = currentYear + 1;
}
System.out.println("The poplulation in " + years + " years is " + currentpop);
}
}