1.while循环结构
语法:
while(循环条件)
{
循环操作;
}
实例:
int count = 1; //循环计数器初始为1
while(count<=36) {//循环终止条件为达到36
System.out.println("复印第"+count+"份试卷"); //循环内容
count++;//改变循环条件,已复印试卷加1 //计数器累加
}
1.2 do-while循环
语法:
do{
循环操作;
}while(循环条件);
实例:
int score;
Scanner input = new Scanner(System.in);
do {
System.out.println("学生参加考试!");
System.out.print("老师请输入学生考试成绩:");
score = input.nextInt();
} while(score<60);
System.out.println("恭喜你,考试成绩合格!");