大佬們能不能幫看看
public?class?HelloWorld?{
????public?static?void?main(String[]?args)?{
????????
????????//?變量保存成績
????????int?score?=?53;?
????????
????????//?變量保存加分次數
????????int?count?=?0;
????????//打印輸出加分前成績?
??????????
???????System.out.println(score);
????????
????????//?只要成績小于60,就循環執行加分操作,并統計加分次數
????????
????????for(count=0;score<60;count++)
????????score+=1;
????????
????????
????????
????????
????????
????????//打印輸出加分后成績,以及加分次數
??????System.out.println(score);
????}
}
2023-03-09
17行count已經被定義過,你就不能再用了,改成i好一些
public class HelloWorld {
? ? public static void main(String[] args) {
? ? ? ??
? ? ? ? // 變量保存成績
? ? ? ? int score = 53;?
? ? ? ??
? ? ? ? // 變量保存加分次數
? ? ? ? int count = 0;
? ? ? ??
? ? ? ? //打印輸出加分前成績?
? ? ? ? ??
? ? ? ?System.out.println("加分前的成績:"+score);
? ? ? ??
? ? ? ? // 只要成績小于60,就循環執行加分操作,并統計加分次數
? ? ? ? for(int i=0;score<60;i++){
? ? ? ? ? ? score++;
? ? ? ? ? ? count++;
? ? ? ? ? ? while(score==60){
? ? ? ? ? ? ? ? break;
? ? ? ? ? ? }
? ? ? ? }
? ? ? ? System.out.println("加分后的成績:"+score);
? ? ? ? System.out.println("加分次數:"+count);
? ? ? ? //打印輸出加分后成績,以及加分次數
? ? ??
? ? }
}
2022-11-17
public?class?HelloWorld?{ ????public?static?void?main(String[]?args)?{ ????????//?變量保存成績 ????????int?score?=?53; ????????//?變量保存加分次數 ????????int?count?=?0; ????????//打印輸出加分前成績 ????????System.out.println("加分前成績:"?+?score); ????????//?只要成績小于60,就循環執行加分操作,并統計加分次數 ????????for?(int?i?=?score;?i?<?60;?i++)?{ ????????????score+=1; ????????????count+=1; ????????} ????????//打印輸出加分后成績,以及加分次數 ????????System.out.println("加分后成績:"?+?score); ????????System.out.println("共加了"?+?count?+?"次"); ????} }2022-11-17
HelloWorld?{ ????(String[]?args)?{ ????????score?=?count?=?System..println(+?score)(i?=?scorei?<?i++)?{ ????????????score+=count+=} ????????System..println(+?score)System..println(+?count?+?)} }2022-11-16
public class HelloWorld {
? ? public static void main(String[] args) {
? ? ? ??
? ? ? ? // 變量保存成績
? ? ? ? int score = 53;?
? ? ? ??
? ? ? ? // 變量保存加分次數
? ? ? ? int count = 0;
? ? ? ? //打印輸出加分前成績?
? ? ? ? ? System.out.println("加分前成績:"+score);
? ? ? ?
? ? ? ??
? ? ? ? // 只要成績小于60,就循環執行加分操作,并統計加分次數
? ? ? ? while(score<60)
? ? ? ? {
? ? ? ? ? ? count++;
? ? ? ? ? ? score++;
? ? ? ? }
? ? ? ??
? ? ? ? //打印輸出加分后成績,以及加分次數
? ? ? System.out.println("加分后成績:"+score);
? ? ? System.out.println("共加了:"+count+"次!");
? ? }
}
2022-11-05