怎么錯啦,找不到?。。。?!
System.out.println("加分前成績"+score);
? ? ? ? if(score<60){
? ? ? ? score++;
? ? ? ? count++;
? ? ? ? }
? ? ? ? System.out.println("加分后成績"+score);
? ? ? ? System.out.println("共加了"+count+"次!");
System.out.println("加分前成績"+score);
? ? ? ? if(score<60){
? ? ? ? score++;
? ? ? ? count++;
? ? ? ? }
? ? ? ? System.out.println("加分后成績"+score);
? ? ? ? System.out.println("共加了"+count+"次!");
2016-05-15
舉報
2016-05-15
用if不是循環(huán),是條件判斷。
你只判斷了一次!判斷<60,然后就++了一次。
可以用for,while
2016-05-15
public class HelloWorld {
? ? public static void main(String[] args) {
? ? ? ??
? ? ? ?// 變量保存成績
? ? ? ? int score = 53;?
? ? ? ??
? ? ? ? // 變量保存加分次數(shù)
? ? ? ? int count = 0;
? ? ? ? System.out.println("加分前成績:"+score);
? ? ? ? //打印輸出加分前成績
? ? ? ??
? ? ? ? for(;score<60;count++){
? ? ? ? ? ??
? ? ? ? ? ? score++;
? ? ? ? } ?
? ? ? ?
? ? ? ??
? ? ? ? // 只要成績小于60,就循環(huán)執(zhí)行加分操作,并統(tǒng)計加分次數(shù)
? ? ? ? System.out.println("加分后的成績"+score);
? ? ? ? System.out.println("共加了"+count+"次");
? ? ? ??
? ? ? ??
? ? ? ??
? ? ? ??
? ? ? ??
? ? ? ??
? ? ? ??
? ? ? ? //打印輸出加分后成績,以及加分次數(shù)
? ? ??
? ? }
}