continue;//表示继续,当遇到continue语句时,则结束当次循环继续执行下一次循环  例子:

  

 1 class For09{
 2     public static void main(String[ ]args){
 3         //输入5个人Java学生的考试成绩,统计成绩在95分以上的人数
 4         Scanner input = new Scanner(System.in);
 5         int count = 0;    //表示统计95分以上的人数
 6         for(int i = 1 ; i <=5 ; i ++){
 7             System.out.print("请输入第"+ i +"个人的成绩:");
 8             double score = input.nextDouble();
 9             //判断,当前成绩score,如果在95分及以下则继续输入下一个人成绩
10             if(score <=95){
11                 continue;    //表示继续,当遇到continue语句时,则结束当次循环继续执行下一次循环
12             }
13             //统计95分以上的人数
14             count++;
15         }
16         System.out.println("在95分以上的成绩的人数有:"+ count);
17     }
18 }

 

相关文章:

  • 2022-12-23
  • 2021-12-14
  • 2022-02-22
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-14
猜你喜欢
  • 2022-12-23
  • 2021-12-25
  • 2021-04-22
  • 2021-12-18
  • 2021-12-10
  • 2022-12-23
  • 2021-04-24
相关资源
相似解决方案