import java.io.*;
import java.util.*;
public class popGrowth
{
public static void main (String args[])
{
Scanner keyboard = new Scanner(System.in);
double rate = keyboard.nextDouble();
while (rate != 0.0){ //stops it at zero
double initialPop = 236; //in millions
for (int i = 0; i < 20; i++)// i establishes the year
{
int year = i + 2010;// starts the year at 2010
double population = initialPop * Math.pow(1+rate/(double)(12*100), (12*i)); //finds population
System.out.println("Year: /tPopulation in millions");
System.out.println(year + "/t " + population); //prints year
}
double timeToDouble = 72/rate; //rule of 72
System.out.println("Time to double " + timeToDouble);
System.out.print("Please input new rate ");
rate = keyboard.nextDouble(); //input for zero
}
}
}
这是我的确切代码,我不知道为什么它会在没有错误的情况下编译就无法运行。