慕課網-安卓工程師初養成-5-1 編程練習

來源:互聯網
上載者:User

標籤:style   blog   http   color   ar   strong   for   div   sp   

來源:http://www.imooc.com/code/1554

 

小夥伴們,請根據所學知識,參考注釋,將代碼編輯器中代碼補充完整,實現成績加分功能。

功能描述:為指定成績加分,直到分數大於等於 60 為止,輸出加分前和加分後的成績,並統計加分的次數

運行效果:

任務

溫馨提示: 先試著自己獨立完成,木有思路了也表著急。在後面 3 個小節中, @laurenyang 將分別講解本小節練習的解析思路、最佳化的方案以及如何通過Eclipse的調試功能輔助代碼開發

 1 public class HelloWorld { 2     public static void main(String[] args) { 3          4         // 變數儲存成績 5         int score = 53;  6          7         // 變數儲存加分次數 8         int count = 0; 9 10 11         //列印輸出加分前成績 12           13        14         15         // 只要成績小於60,就迴圈執行加分操作,並統計加分次數16         17         18         19         20         21         22         23         //列印輸出加分後成績,以及加分次數24       25 26 27 28     }29 }

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 1 public class HelloWorld { 2     public static void main(String[] args) { 3          4         // 變數儲存成績 5         int score = 53;  6          7         // 變數儲存加分次數 8         int count = 0; 9 10 11         //列印輸出加分前成績 12         System.out.println("加分前成績: "+score);13        14         15         // 只要成績小於60,就迴圈執行加分操作,並統計加分次數16         for (; score + count < 60; count++) {17             18         }19         20         21         22         23         //列印輸出加分後成績,以及加分次數24         System.out.println("加分後成績: "+(score + count));25         System.out.println("總共加了"+count+"次!");26 27 28     }29 }

 

慕課網-安卓工程師初養成-5-1 編程練習

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.