为了账号安全,请及时绑定邮箱和手机立即绑定

ppppppp

public class HelloWorld {
    public static void main(String[] args) {
       
        // 变量保存成绩
        int score = 53;
       
        // 变量保存加分次数
        int count = 0;


        //打印输出加分前成绩
        System.out.println("加分前成绩:"+score);
         
      
       
        // 只要成绩小于60,就循环执行加分操作,并统计加分次数
        for(int score=53;score<60;count++){
            score++;}
            {
                while(score>=60);
                {
                System.out.println("加分后的成绩:"+score);
                System.out.println("共加了"+count+"次");
        }
       
    }
}
       
       
       
       
        //打印输出加分后成绩,以及加分次数
     


    }
}

还是有一个错误

正在回答

2 回答

两种方法:

第一种:

public class lianxi {

    public static void main(String[] args) {

        

               int score = 53; 

               int count = 0;

               System.out.println("加分前成绩:"+score);

                       while(score<60){

                       score++;

                       count++;

                    

                 }

                System.out.println("加分后的成绩:"+score);

                System.out.println("共加了"+count+"次");

        

        

    }

}

第二种:

public class lianxi {

    public static void main(String[] args) {

        

               int score = 53; 

               int count = 0;

               System.out.println("加分前成绩:"+score);

                       for(;score<60;){

                       score++;

                       count++;

                    

                 }

                System.out.println("加分后的成绩:"+score);

                System.out.println("共加了"+count+"次");

        

        

    }

}

        

        

        


0 回复 有任何疑惑可以回复我~

编译好像就通不过

首先for循环括号里应该是这样吧for(count=0;score<60;count++)

但是这样编译通过后好像执行不了,是不是循环不完善,可以查看同学代码

0 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消
Java入门第一季(IDEA工具)升级版
  • 参与学习       1166193    人
  • 解答问题       17589    个

0基础萌新入门第一课,从Java环境搭建、工具使用、基础语法开始

进入课程
意见反馈 帮助中心 APP下载
官方微信