问题:人口预测
重写编程练习题1.11,提示用户输入年数,然后显示这个年数之后的人口值。使用编程练习题1.11中的提示。
import java.util.Scanner;
public class Population {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.println("Enter the number of years:");
int year = input.nextInt();
double second = 24*60*60;
double born = second/7.0;//每天出生人口
double death = second/13.0;//每天死亡人口
double immigrant = second/45.0;//每天移民人口
double people = born - death + immigrant;//每天增加人口
double peopleYear = people * 365;//每年增加人口
double peopleNow = 312032486;
double a = peopleNow+year*peopleYear;
System.out.println("The population in " + year + "is " + a);
}
}