為指定成績加分,直到分數(shù)大于等于 60 為止,輸出加分前和加分后的成績,并統(tǒng)計加分的次數(shù),為什么代碼是小于60?如下代碼
public class HelloWorld {
? ? public static void main(String[] args) {
? ? ? ??
? ? ? ? // 變量保存成績
? ? ? ? int score = 53;?
? ? ? ??
? ? ? ? // 變量保存加分次數(shù)
? ? ? ? int count = 0;
?System.out.println("加分前成績:"+score);
? ? ? ? //打印輸出加分前成績?
? ? ? ? while(score<60){
? ? ? ? ? ? count++;
? ? ? ? ? ? score++;
? ? ? ? }?
? ? ? ?
? ? ? ??
? ? ? ? // 只要成績小于60,就循環(huán)執(zhí)行加分操作,并統(tǒng)計加分次數(shù)
? ? ? ??
? ? ? ?
? ? ? ? System.out.println("加分前成績:"+score);
? ? ? ? System.out.println("共加了"+count+"次!");
2015-07-07
題意就這么難懂么?加到60,如果while(score<=60)的話,當加到score=60的時候,循環(huán)體內(nèi)還得執(zhí)行一次,score就是61了
2018-03-28
用if怎么寫出來就執(zhí)行一次啊
2016-08-18
等于60就不用加了啊 樓上這是什么問題
2015-07-07
求解,在線等
2015-07-07
為什么是while(score<60),而不是while(score<=60)