編程練習(xí)題
為什么這段代碼放在Myeclipse里面就不行了呢。提示有錯(cuò)誤
package newnew;
public class helloword {
?public static void main(String[] args){
?int score =53;
?int count =0;
?System.out.println("加分前成績(jī):"+score);
?while(score>=60){
??score=score+1;
??count++;
?}
?System.out.println("加分后成績(jī):"+score);
?System.out.println("共加了+count+次!");
}
}
錯(cuò)誤提示:Description?Resource?Path?Location?Type
The value of the local variable count is not used?helloword.java?/wenwen/src/newnew?line 6?Java Problem
2015-11-28
while是當(dāng)條件滿足時(shí)執(zhí)行,應(yīng)該改為score<60,你這樣程序不滿足不能執(zhí)行,另外樓上指出了,你最后一行差標(biāo)點(diǎn)符號(hào)了~~錯(cuò)誤提示里面有說第六行
public?class?HelloWorld?{ ????public?static?void?main(String[]?args)?{ ???????? ????????//?變量保存成績(jī) ????????int?score?=?53;? ???????? ????????//?變量保存加分次數(shù) ????????int?count?=?0;??? ?? ?System.out.println("加分前成績(jī):"+score); ?while(score<=60){ ??score=score+1; ??count++; ?} ?System.out.println("加分后成績(jī):"+score); ?System.out.println("共加了"+count+"次!"); } }2015-11-20
("共加了"+count+"次!");