我的還有沒有問題,大家?guī)臀铱纯?/h1>
import?javax.swing.plaf.synth.SynthEditorPaneUI;
import?java.sql.SQLOutput;
import?java.util.Scanner;
public?class?cdb?{
????public?static?void?main(String[]?args)?{
????????String[]?contentList?=?new?String[35];
????????contentList[0]?=?"【第1周】環(huán)境搭建與語法入門";
????????contentList[1]?=?"【第2周】Java語法之循環(huán)、數(shù)組與方法";
????????contentList[2]?=?"【第3周】面向?qū)ο笾庋b與繼承";
????????contentList[3]?=?"【第4周】面向?qū)ο笾畣卫J脚c多態(tài)";
????????contentList[4]?=?"【第5周】常用工具類(上)";
????????contentList[5]?=?"【第6周】常用工具類(下)";
????????contentList[6]?=?"【第7周】常用工具類(下)";
????????contentList[7]?=?"【第8周】前端基礎(chǔ)之HTML與CSS";
????????contentList[8]?=?"【第9周】前端基礎(chǔ)之JavaScript與綜合案例";
????????contentList[9]?=?"【第10周】Java?Web基礎(chǔ)";
????????contentList[10]?=?"【第11周】Java?Web基礎(chǔ)";
????????contentList[11]?=?"【第12周】常用功能與過濾器";
????????contentList[12]?=?"【第13周】監(jiān)聽器與項目實戰(zhàn)";
????????contentList[13]?=?"【第14周】監(jiān)聽器與項目實戰(zhàn)";
????????contentList[14]?=?"【第15周】MySQL基礎(chǔ)";
????????contentList[15]?=?"【第16周】MySQL基礎(chǔ)";
????????contentList[16]?=?"【第17周】Java數(shù)據(jù)庫開發(fā)基礎(chǔ)";
????????contentList[17]?=?"【第18周】框架前置知識";
????????contentList[18]?=?"【第19周】MyBatis基礎(chǔ)";
????????contentList[19]?=?"【第20周】MyBatis實現(xiàn)OA系統(tǒng)項目實戰(zhàn)";
????????contentList[20]?=?"【第21周】MyBatis實現(xiàn)OA系統(tǒng)項目實戰(zhàn)";
????????contentList[21]?=?"【第22周】Linux環(huán)境搭建與Redis應(yīng)用";
????????contentList[22]?=?"【第23周】Spring基礎(chǔ)";
????????contentList[23]?=?"【第24周】Spring基礎(chǔ)";
????????contentList[24]?=?"【第25周】Spring基礎(chǔ)";
????????contentList[25]?=?"【第26周】SSM開發(fā)社交網(wǎng)站";
????????contentList[26]?=?"【第27周】Spring?Boot電商項目實戰(zhàn)";
????????contentList[27]?=?"【第28周】Spring?Boot電商項目實戰(zhàn)";
????????contentList[28]?=?"【第29周】面試";
????????contentList[29]?=?"【第30周】多線程與分布式";
????????contentList[30]?=?"【第31周】多線程與分布式";
????????contentList[31]?=?"【第32周】Spring?Cloud基礎(chǔ)";
????????contentList[32]?=?"【第33周】Spring?Cloud電商實戰(zhàn)";
????????contentList[33]?=?"【第34周】Spring?Cloud電商實戰(zhàn)";
????????contentList[34]?=?"【第35周】Zookeeper+Dubbo應(yīng)用與面試";
????????System.out.println("您要開始第幾周學習啦,直接輸入數(shù)字吧:");
????????int?i?=?new?Scanner(System.in).nextInt();
????????if?(i?>?0?&&?i?<?35)?{
????????????//計算今天是幾月(1-月第一周、4-月第4周)
????????????int?a?=?((i?-?1)?/?4?+?1);
????????????System.out.println("這是第"?+?a?+?"月");
????????????//計算輸入的周是這個月的第幾周
????????????int?b?=?i?-?(a?-?1)?*?4;
????????????System.out.println("這是第"?+?b?+?"周");
????????????//提示信息
????????????System.out.println("以下是您本月的學習計劃,?√?代表當周學習任務(wù)");
????????????System.out.println("=======================================");
????????????//利用for循環(huán),找到數(shù)組中對應(yīng)這個月的內(nèi)容輸出
????????????for?(int?c?=?4?*?a?-?3;?c?>=?4?*?a?-?3?&&?c?<=?4?*?a;?c++)?{
????????????????if?(c?==?i)?{
????????????????????System.out.println("√"?+?contentList[c?-?1]);
????????????????}?else?{
????????????????????System.out.println(contentList[c?-?1]);
????????????????}
????????????}
????????}?else?{
????????????System.out.println("超過最大時間");
????????}
????}
}
import?javax.swing.plaf.synth.SynthEditorPaneUI; import?java.sql.SQLOutput; import?java.util.Scanner; public?class?cdb?{ ????public?static?void?main(String[]?args)?{ ????????String[]?contentList?=?new?String[35]; ????????contentList[0]?=?"【第1周】環(huán)境搭建與語法入門"; ????????contentList[1]?=?"【第2周】Java語法之循環(huán)、數(shù)組與方法"; ????????contentList[2]?=?"【第3周】面向?qū)ο笾庋b與繼承"; ????????contentList[3]?=?"【第4周】面向?qū)ο笾畣卫J脚c多態(tài)"; ????????contentList[4]?=?"【第5周】常用工具類(上)"; ????????contentList[5]?=?"【第6周】常用工具類(下)"; ????????contentList[6]?=?"【第7周】常用工具類(下)"; ????????contentList[7]?=?"【第8周】前端基礎(chǔ)之HTML與CSS"; ????????contentList[8]?=?"【第9周】前端基礎(chǔ)之JavaScript與綜合案例"; ????????contentList[9]?=?"【第10周】Java?Web基礎(chǔ)"; ????????contentList[10]?=?"【第11周】Java?Web基礎(chǔ)"; ????????contentList[11]?=?"【第12周】常用功能與過濾器"; ????????contentList[12]?=?"【第13周】監(jiān)聽器與項目實戰(zhàn)"; ????????contentList[13]?=?"【第14周】監(jiān)聽器與項目實戰(zhàn)"; ????????contentList[14]?=?"【第15周】MySQL基礎(chǔ)"; ????????contentList[15]?=?"【第16周】MySQL基礎(chǔ)"; ????????contentList[16]?=?"【第17周】Java數(shù)據(jù)庫開發(fā)基礎(chǔ)"; ????????contentList[17]?=?"【第18周】框架前置知識"; ????????contentList[18]?=?"【第19周】MyBatis基礎(chǔ)"; ????????contentList[19]?=?"【第20周】MyBatis實現(xiàn)OA系統(tǒng)項目實戰(zhàn)"; ????????contentList[20]?=?"【第21周】MyBatis實現(xiàn)OA系統(tǒng)項目實戰(zhàn)"; ????????contentList[21]?=?"【第22周】Linux環(huán)境搭建與Redis應(yīng)用"; ????????contentList[22]?=?"【第23周】Spring基礎(chǔ)"; ????????contentList[23]?=?"【第24周】Spring基礎(chǔ)"; ????????contentList[24]?=?"【第25周】Spring基礎(chǔ)"; ????????contentList[25]?=?"【第26周】SSM開發(fā)社交網(wǎng)站"; ????????contentList[26]?=?"【第27周】Spring?Boot電商項目實戰(zhàn)"; ????????contentList[27]?=?"【第28周】Spring?Boot電商項目實戰(zhàn)"; ????????contentList[28]?=?"【第29周】面試"; ????????contentList[29]?=?"【第30周】多線程與分布式"; ????????contentList[30]?=?"【第31周】多線程與分布式"; ????????contentList[31]?=?"【第32周】Spring?Cloud基礎(chǔ)"; ????????contentList[32]?=?"【第33周】Spring?Cloud電商實戰(zhàn)"; ????????contentList[33]?=?"【第34周】Spring?Cloud電商實戰(zhàn)"; ????????contentList[34]?=?"【第35周】Zookeeper+Dubbo應(yīng)用與面試"; ????????System.out.println("您要開始第幾周學習啦,直接輸入數(shù)字吧:"); ????????int?i?=?new?Scanner(System.in).nextInt(); ????????if?(i?>?0?&&?i?<?35)?{ ????????????//計算今天是幾月(1-月第一周、4-月第4周) ????????????int?a?=?((i?-?1)?/?4?+?1); ????????????System.out.println("這是第"?+?a?+?"月"); ????????????//計算輸入的周是這個月的第幾周 ????????????int?b?=?i?-?(a?-?1)?*?4; ????????????System.out.println("這是第"?+?b?+?"周"); ????????????//提示信息 ????????????System.out.println("以下是您本月的學習計劃,?√?代表當周學習任務(wù)"); ????????????System.out.println("======================================="); ????????????//利用for循環(huán),找到數(shù)組中對應(yīng)這個月的內(nèi)容輸出 ????????????for?(int?c?=?4?*?a?-?3;?c?>=?4?*?a?-?3?&&?c?<=?4?*?a;?c++)?{ ????????????????if?(c?==?i)?{ ????????????????????System.out.println("√"?+?contentList[c?-?1]); ????????????????}?else?{ ????????????????????System.out.println(contentList[c?-?1]); ????????????????} ????????????} ????????}?else?{ ????????????System.out.println("超過最大時間"); ????????} ????} }
2022-02-13
代碼運行邏輯沒有問題,僅提供些許建議
類名首字母最好按規(guī)范命名為大寫;
提示用戶輸入第幾周,實際為n+1周, 輸入0代表第一周,不大合適, 最好是1-35,? 然后判斷來減1
for循環(huán)語句,直接采用 for(int i = 0; i < 4; i++)即可,在里面判斷是否超限,然后continue,代碼會更加美觀