第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定

哪里加入try-catch語句,如果輸入的生日格式錯誤就不顯示星座和分析

請問在哪里加入try-catch語句。如果輸入的生日格式錯誤就不顯示星座和分析

Scanner?sc=new?Scanner(System.in);

??????System.out.println("請輸入年:");

?int?year=sc.nextInt();
????
??????System.out.println("請輸入月:");

??????int?month=sc.nextInt();

??????System.out.println("請輸入日:");??

??????int?day=sc.nextInt();

??????if(year<0||month<0||month>12||day>31||day<0){

???????System.out.println("輸入錯誤,請從新輸入");

??????}

??????System.out.println(year+"-"+month+"-"+day);

????if(month==12){

????if(day>=22&&day<=31){

????????}

??????try?{

?}?catch?(Exception?e)?{

??System.out.println("不旨行");

?}
??????System.out.println("請輸入正確的格式:如1992-12-21");

????????System.out.println("摩羯座(12.22-1.19)");

????????System.out.println("***********星座分析***********");

????????System.out.println("?星座特征:現(xiàn)實、安全、平穩(wěn).?");

????????System.out.println("?幸運色:暗綠色??");

????????System.out.println("??幸運數(shù):6??");

????????System.out.println("幸運日:星期三?");

????????System.out.println("幸運地點:遠離嘈雜的地點??");

????????System.out.println("個性特征:你深思謹慎,冷靜而準確的判斷力,給人沉穩(wěn)而嚴肅的印象。你有強烈的責任感和企業(yè)圖心,時時鞭策自己努力實現(xiàn)理想。但是,你凡事都太過認真,乃至拘泥,而顯得過于剛強,冥頑不靈。???");

???????System.out.println("?星座優(yōu)點:1、有實際的人生觀;2、做事腳踏實地;3、意志力強,不容易受影響;4、處處謹慎;5、有克服困難的毅力;6、堅守原則,重視紀律;7、有家庭觀念;"?+

??????????????????"?8、對人謙遜;9、有獨樹一格的幽默感;?");

??????System.out.println("?星座缺點:1、太過現(xiàn)實;2、固執(zhí);3、不夠樂觀;4、個人利已主義;5、缺乏浪漫情趣;6、過于壓抑自己的欲望;7、太專注于個人的目標;8、缺乏對人群的關(guān)懷和熱情");

????????System.out.println("?星座朋友:雙魚座、天蝎座、處女座");

?

正在回答

1 回答


SimpleDateFormat?dateFormat=new?SimpleDateFormat("yyyy-MM-dd");
Date?date=null;
try?{
???date=dateFormat.parse(str);
}?catch?(ParseException?e)?{
????//日期格式錯誤。。。。。。。
???
}


0 回復 有任何疑惑可以回復我~

舉報

0/150
提交
取消

哪里加入try-catch語句,如果輸入的生日格式錯誤就不顯示星座和分析

我要回答 關(guān)注問題
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號