下面是应该运算示例:
Enter the number of years : 5
The populationin5 years is 325932970
package Second;
import java.util.Scanner;
public class Average {
public static void main(String[] args) {
System.out.print("Enter the number of years :");
Scanner input = new Scanner(System.in);
int n = input.nextInt();
int sum = 312032486;
double birth = 1.0 / 7, dead = 1.0 / 13, move = 1.0 / 45;
int year = 365*24*60*60;
for(int i = 1; i <= n; i++) {
int nYear = (int)(sum + year * birth - year * dead + year * move);
}
System.out.println("The populationin 5 years is:"+ sum);
}
}
输出
Enter the number of years :5 The populationin 5 years is:312032486



