The U.S. Census Bureau projects population based on the following assumptions:
One birth every 7 seconds
One death every 13 seconds
One new immigrant every 45 seconds
For this lesson write a program to display the population for each of the next five years. Assume the current population is 312,032,486 and one year has 365 days. Hint: In Java, if two integers perform division, the result is an integer. The fraction part is truncated. For example, 5 / 4 is 1 (not 1.25) and 10 / 4 is 2 (not 2.5).
Breaking it down
Representing the number of years we will use java 8 to create a range of numbers then use a forEach to iterate through the elements. Within the java 8 function the yearly population will be calculated by adding the births, immigrants and base population while subtracting the number of deaths. Finally formatting and outputting the results.