任务:2006年培养学员8万人,每年增长%25,请问按此增长速度,到那一年培训学员人数将达到20万人

01.for

package zuoye;

public class zuoye {

public static void main(String[] args) {

int a = 2006;// 定义最初年份

double i = 1.25;// 每年增长%25

for (int x = 8; x <= 20; a++) {

x = (int) (x * 1.25);// 运算公式

if (x == 20)// 判断

break;// 如果x=20就跳出循环

}

System.out.println("培训学员人数将达到20万人:" + a);// 输出结果

// TODO 自动生成的方法存根

}

}

02. do……..while

package zuoye;

public class zuoye1 {

public static void main(String[] args) {

int x = 8;// 定义学员8万人

int a = 2006;// 定义最初年份

double i = 1.25;// 每年增长%25

do {

x = (int) (x * 1.25);// 运算公式

a++;// 年份自增

} while (x < 20);// 小于20万人

System.out.println("培训学员人数将达到20万人:" + a);// 输出结果

// TODO 自动生成的方法存根

 

}

}

03.whlie

package zuoye;

public class zuoye02 {

public static void main(String[] args) {

int x = 8;// 定义学员8万人

int a = 2006;// 定义最初年份

double i = 1.25;// 每年增长%25

while (x < 20)// 小于20万人

{

x = (int) (x * 1.25);// 运算公式

a++;// 年份自增

}

System.out.println("培训学员人数将达到20万人:" + a);// 输出结果

// TODO 自动生成的方法存根

 

}

 

}

任务:2006年培养学员8万人,每年增长%25,请问按此增长速度,到那一年培训学员人数将达到20万人任务:2006年培养学员8万人,每年增长%25,请问按此增长速度,到那一年培训学员人数将达到20万人任务:2006年培养学员8万人,每年增长%25,请问按此增长速度,到那一年培训学员人数将达到20万人任务:2006年培养学员8万人,每年增长%25,请问按此增长速度,到那一年培训学员人数将达到20万人

相关文章:

  • 2021-08-30
  • 2021-08-29
  • 2021-09-14
  • 2021-07-02
  • 2021-07-01
  • 2021-09-27
  • 2021-06-22
猜你喜欢
  • 2021-05-12
  • 2021-06-15
  • 2021-11-20
  • 2022-01-01
  • 2022-12-23
  • 2022-01-05
相关资源
相似解决方案