NO IMAGE

“據日本共同社7月30日報道,聯合國經濟和社會事務部29日釋出預測稱,到2050年,全球人口將從目前(2015年)的73億人增至97億人,至2100年將達到112億人。”

—-http://money.163.com/15/0730/09/AVOSTAMV00254TI5.html

通過程式碼演算,以上預測基於以下年化增長率(參考執行結果中高亮顯示的兩個數值):

2015年至2050年,世界總人口年化增長率為0.8%;

2015年至2100年,世界總人口年化增長率為0.5%;

 

程式碼如下:

//Java how to program, 10th edtion
//Exercise 4.39, making difference-World Population Growth
/**(World Population Growth) World population has grown considerably over the centuries.
Continued growth could eventually challenge the limits of breathable air, drinkable water, arable
cropland and other limited resources. There’s evidence that growth has been slowing in recent years
and that world population could peak some time this century, then start to decline.
For this exercise, research world population growth issues online. Be sure to investigate various
viewpoints. Get estimates for the current world population and its growth rate (the percentage by
which it’s likely to increase this year). Write a program that calculates world population growth
each year for the next 75 years, using the simplifying assumption that the current growth rate will stay
constant. Print the results in a table. The first column should display the year from year 1 to year
75. The second column should display the anticipated world population at the end of that year.
The third column should display the numerical increase in the world population that would occur
that year. Using your results, determine the year in which the population would be double what it
is today, if this year’s growth rate were to persist.*/
public class PopulationTest {
public static void main(String[] args){
int base=73;
double growth_rate_low=0.003;
double growth_rate_middle=0.005;
double growth_rate_high=0.008;
double populationEstimated=base;
int counter=1;
int YEARS=85;
System.out.print("Year\t\t");
System.out.print("EP(Low)\t\t");
System.out.print("EP(Mid)\t\t");
System.out.print("EP(High)\t");
System.out.print("Growth(Mid)\n");
while(counter<=YEARS){
System.out.printf("%d\t\t",2015 counter);
System.out.printf("%.2f\t\t",base*Math.pow(1.0 growth_rate_low, counter));
System.out.printf("%.2f\t\t",base*Math.pow(1.0 growth_rate_middle, counter));
System.out.printf("%.2f\t\t",base*Math.pow(1.0 growth_rate_high, counter));
System.out.printf("%.2f\t\n",base*(Math.pow(1.0 growth_rate_middle, counter)-Math.pow(1.0 growth_rate_middle, counter-1)));
counter  ;
}
}
}

 

執行結果:

Year  EP(Low)  EP(Mid)  EP(High) Growth(Mid)
2016  73.22  73.37  73.58  0.36 
2017  73.44  73.73  74.17  0.37 
2018  73.66  74.10  74.77  0.37 
2019  73.88  74.47  75.36  0.37 
2020  74.10  74.84  75.97  0.37 
2021  74.32  75.22  76.57  0.37 
2022  74.55  75.59  77.19  0.38 
2023  74.77  75.97  77.80  0.38 
2024  74.99  76.35  78.43  0.38 
2025  75.22  76.73  79.05  0.38 
2026  75.45  77.12  79.69  0.38 
2027  75.67  77.50  80.32  0.39 
2028  75.90  77.89  80.97  0.39 
2029  76.13  78.28  81.62  0.39 
2030  76.35  78.67  82.27  0.39 
2031  76.58  79.06  82.93  0.39 
2032  76.81  79.46  83.59  0.40 
2033  77.04  79.86  84.26  0.40 
2034  77.28  80.26  84.93  0.40 
2035  77.51  80.66  85.61  0.40 
2036  77.74  81.06  86.30  0.40 
2037  77.97  81.47  86.99  0.41 
2038  78.21  81.87  87.68  0.41 
2039  78.44  82.28  88.38  0.41 
2040  78.68  82.69  89.09  0.41 
2041  78.91  83.11  89.80  0.41 
2042  79.15  83.52  90.52  0.42 
2043  79.39  83.94  91.25  0.42 
2044  79.63  84.36  91.98  0.42 
2045  79.86  84.78  92.71  0.42 
2046  80.10  85.21  93.45  0.42 
2047  80.34  85.63  94.20  0.43 
2048  80.58  86.06  94.96  0.43 
2049  80.83  86.49  95.72  0.43 
2050  81.07  86.92  96.48  0.43 
2051  81.31  87.36  97.25  0.43 
2052  81.56  87.79  98.03  0.44 
2053  81.80  88.23  98.82  0.44 
2054  82.05  88.67  99.61  0.44 
2055  82.29  89.12  100.40  0.44 
2056  82.54  89.56  101.21  0.45 
2057  82.79  90.01  102.02  0.45 
2058  83.04  90.46  102.83  0.45 
2059  83.28  90.91  103.65  0.45 
2060  83.53  91.37  104.48  0.45 
2061  83.78  91.83  105.32  0.46 
2062  84.04  92.28  106.16  0.46 
2063  84.29  92.75  107.01  0.46 
2064  84.54  93.21  107.87  0.46 
2065  84.79  93.68  108.73  0.47 
2066  85.05  94.14  109.60  0.47 
2067  85.30  94.61  110.48  0.47 
2068  85.56  95.09  111.36  0.47 
2069  85.82  95.56  112.25  0.48 
2070  86.07  96.04  113.15  0.48 
2071  86.33  96.52  114.05  0.48 
2072  86.59  97.00  114.97  0.48 
2073  86.85  97.49  115.89  0.49 
2074  87.11  97.98  116.81  0.49 
2075  87.37  98.47  117.75  0.49 
2076  87.64  98.96  118.69  0.49 
2077  87.90  99.45  119.64  0.49 
2078  88.16  99.95  120.60  0.50 
2079  88.43  100.45  121.56  0.50 
2080  88.69  100.95  122.53  0.50 
2081  88.96  101.46  123.51  0.50 
2082  89.22  101.96  124.50  0.51 
2083  89.49  102.47  125.50  0.51 
2084  89.76  102.99  126.50  0.51 
2085  90.03  103.50  127.51  0.51 
2086  90.30  104.02  128.53  0.52 
2087  90.57  104.54  129.56  0.52 
2088  90.84  105.06  130.60  0.52 
2089  91.12  105.59  131.64  0.53 
2090  91.39  106.12  132.70  0.53 
2091  91.66  106.65  133.76  0.53 
2092  91.94  107.18  134.83  0.53 
2093  92.21  107.71  135.91  0.54 
2094  92.49  108.25  137.00  0.54 
2095  92.77  108.79  138.09  0.54 
2096  93.05  109.34  139.20  0.54 
2097  93.33  109.89  140.31  0.55 
2098  93.61  110.43  141.43  0.55 
2099  93.89  110.99  142.56  0.55 
2100  94.17  111.54  143.70  0.55