展开全部
用 java编写:输入任e68a84e8a2ad3231313335323631343130323136353331333366306438意年份和月份,输出对应月份的天数,首先判断输入年份是否是闰年,然后使用switch 方法判断月份,判断代码如下:
public class GetDays {
public static int getDays(int year, int month) {
int days = 0;
boolean isLeapYear = false;
if (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0)) {
System.out.println("这一年是闰年");
isLeapYear = true;
} else {
System.out.println("这一年不是闰年");
isLeapYear = false;
}
switch (month) {
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
days = 31;
break;
case 2:
if (isLeapYear) {
days = 29;
} else {