题目:2006年培养学员8万人,每年增长25%,请问按照次增长速度,到哪一年培养学员人数将达到20万人?(while ,do while ,for)
程序源代码:
while:
public class First {
public static void main(String[] args) {
// TODO Auto-generated method stub
double a=8; //2006年的人数
double b= 1.25; //每年增加的百分比为0.25
int c=2006; //开始的年份
while(a<=20) //while的判断条件
{
a=a*b; //a每增加一年的人数
c++; //每增加一年的人数,年份加1
}
System.out.println("到"+c+"年人数达到20万");
//输出结果
}
}