Print Year Month
Submit solution
Points:
40 (partial)
Time limit:
1.0s
Memory limit:
64M
Authors:
Problem types
Allowed languages
Java 19, Java 8
題目說明
輸入西元年、月,
判斷是否為閏年、該月有幾天
【閏年規則】西元年份
為4的倍數但非100的倍數
,或為400的倍數
,為閏年。
舉例:1700年、1800年、1900年、2100年、2200年、2300年為平年。1600年、2000年及2400年為閏年。
輸入
西元年、月(數字)
輸出
若為閏年,輸出(year) is leap year.
,否則輸出(year) is not leap year.
第二行輸出(月份) has (天數) days.
,若月份代號錯誤則輸出Error month: (月份代號)
1 -> "January";
2 -> "February";
3 -> "March";
4 -> "April";
5 -> "May";
6 -> "June";
7 -> "July";
8 -> "August";
9 -> "September";
10 -> "October";
11 -> "November";
12 -> "December";
default -> "Error month: " + month;
// 提醒:DMOJ不支援Java12,switch不能使用箭號寫法
sample input1
2024
2
sample output1
2024 is leap year.
February has 29 days.
sample input2
1999
12
sample output2
1999 is not leap year.
December has 31 days.
sample input3
1900
20
sample output3
1900 is not leap year.
Error month: 20
Comments