int year=0,month=0,day=0,sum=0; do{ System.out.println("請(qǐng)輸入年"); if(input.hasNext()){ year=input.nextInt(); if(year>=1900){ }else{ System.out.println("錯(cuò)誤!輸入的年份不能小于1900年;\n請(qǐng)重新輸入"); }while(true); } System.out.println("請(qǐng)輸入月"); if(input.hasNext()){ month=input.nextInt(); if(month<=12||month>=1){ }else{ System.out.println("錯(cuò)誤!你輸入的月份有誤;"); while(true); } } System.out.println("請(qǐng)輸入日"); if(input.hasNext()){ day=input.nextInt(); if(day<=31&day>=1){ if(day<=31&&month==1||month==3||month==5||month==7||month==8||month==10||month==12){ }else if(day<=30&&month==4||month==6||month==9||month==11){ }else if(month==2&&day<=29&&(year%4==0&&year%100!=0||year%400==0)){ }else if(month==2&&day<=28){ }else{ System.out.println("錯(cuò)誤!"+year+"年的"+month+"月沒(méi)有"+day+"天"); while(true); } }else{ System.out.println("錯(cuò)誤!"+year+"年的"+month+"月沒(méi)有"+day+"天"); while(true); } } }while(true); } }
添加回答
舉報(bào)
0/150
提交
取消