這是哪錯了?
public class HelloWorld {
? ? public static void main(String[] args) {
? ? ? ??
? ? ? ? // 變量保存成績
? ? ? ? int score = 53;?
? ? ? ??
? ? ? ? // 變量保存加分次數(shù)
? ? ? ? int count = 0;
? ? System.out.println("加分前成績:"+score); ? ?//打印輸出加分前成績?
? ? while(score<60) {score=score+count; count++} ? ? ?
? ? ?
? ? ? ??
? ? ? ? // 只要成績小于60,就循環(huán)執(zhí)行加分操作,并統(tǒng)計加分次數(shù) ??
? ? ?System.out.println("加分后成績:"+score); ??
? ? ?System.out.println("總共加了"+score+" 次"); ??
? ? ? ??
? ? ? ? //打印輸出加分后成績,以及加分次數(shù)
? ? ??
? ? }
}
2016-04-17
int score=53;
int times = 0;
System.out.println("加分前的成績是:"+score);
while (score<60) {
score++;
times++;
}
System.out.println("加分后的成績是:"+score);
System.out.println("加分的次數(shù)是:"+times);
2016-04-13
score=score+count;這句不對,因為你這時候count是0;相當(dāng)于你第一次循score還是53;
最后的count多加了一次。
2016-04-13
? ?System.out.println("加分前成績:"+score); ? ?//打印輸出加分前成績?
? ? ? ?while(score<60) {score++; count++;} ? ? ? ?
? ? ?
? ? ? ??
? ? ? ? // 只要成績小于60,就循環(huán)執(zhí)行加分操作,并統(tǒng)計加分次數(shù) ??
? ? ?System.out.println("加分后成績:"+score); ??
? ? ?System.out.println("總共加了"+score+" 次"); ??
? ? ? ??
? ? ??