分析:
根据月份可以判断:
1、3、5、7、8、10、12月份是31天
4、6、9、11月份是30天
2月份闰年为29天,非闰年为28天
具体代码如下:
int month = 6;
switch (month){
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12: System.out.println(month+"是31天");break;
case 2: System.out.println(month+"月闰年为29天,非闰年为28天");break;
case 4:
case 6:
case 9:
case 11: System.out.println(month+"是30天");break;
default:
System.out.println("数据有误!");
}
}
}