我這個哪里錯了,有誰解釋一下嗎
public class HelloWorld {
? ? public static void main(String[] args) {
? ? ? ??
? ? ? ? // 變量保存成績
? ? ? ? int score = 53;?
? ? ? ??
? ? ? ? // 變量保存加分次數
? ? ? ? int count = 0;
? ? ? ??
? ? ? ? //打印輸出加分前成績?
? ? ? ? System.out.println("加分前成績:"+score);??
? ? ? ??
? ? ? ? // 只要成績小于60,就循環執行加分操作,并統計加分次數
? ? ? ? if(score<60;score++;count++){
? ? ? ? ? ? System.out.println("加分后成績:"+score);
? ? ? ? ? ??
? ? ? ? }
? ? ? ??
? ? ? ? //打印輸出加分后成績,以及加分次數
? ? ? System.out.println("共加了"+count+"次!");
? ? }
}
2018-08-30
對對,IF只能寫判斷語句。...
2018-08-30
if里面出問題了,你可以使用if作為判斷條件,在if大括號里面使用循環:if(score<=60){
??????????? for(int newscore=score;newscore<60;newscore++){
??????????????? score++;
??????????????? count++;
??????????? }
??????? }
2018-08-26
if括號里面怎么能寫循環呢?括號里面只能寫判斷語句,兄弟
2018-08-26
for(score<60;score++;count++)/*if改為for*/{
? ?score+=count;//你未進行加分操作,當然也不存在加分計數了,然后副作用就是score不能加到60,無限循環
//你的count只會無窮大 ? ? ? ??
//System.out.println("加分后成績:"+score);這個的話我沒記錯題目要求應該是只用打印一遍最終成績吧
//所以不用放在循環里面
//額,才看見for是代表循環,if代表判斷語句,嗯嗯 ? ? ?
? ? ? ? }
System.out.println("加分后成績:"+score);
//嗯,這樣就行了,//的意思是單行注釋這個應該知道吧
/*還是注釋,希望能幫到你*/
2018-08-26
if里面循壞寫錯了