已知某年某月,请输出这个月共有多少天(switch语句)
来源:互联网 发布:淘宝网餐桌 编辑:程序博客网 时间:2024/05/16 06:18
package com.zhidi;
public class Lianxi08 {
public static void main(String[] args) {
// 已知某年某月,请输出这个月共有多少天。(switch语句)
int year = 2012;
int month = 2;
switch(month){
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
System.out.println(year+"年"+month+"月一共有31天");
break;
case 4:
case 6:
case 9:
case 11:
System.out.println(year+"年"+month+"月一共有30天");
break;
case 2:
if(year%4==0 && year%100!=0 || year%400==0){
System.out.println(year+"年"+month+"月一共有29天");
}else{
System.out.println(year+"年"+month+"月一共有28天");
}
break;
default:
System.out.println("输入错误");
}
}
}
public class Lianxi08 {
public static void main(String[] args) {
// 已知某年某月,请输出这个月共有多少天。(switch语句)
int year = 2012;
int month = 2;
switch(month){
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
System.out.println(year+"年"+month+"月一共有31天");
break;
case 4:
case 6:
case 9:
case 11:
System.out.println(year+"年"+month+"月一共有30天");
break;
case 2:
if(year%4==0 && year%100!=0 || year%400==0){
System.out.println(year+"年"+month+"月一共有29天");
}else{
System.out.println(year+"年"+month+"月一共有28天");
}
break;
default:
System.out.println("输入错误");
}
}
}
0 0
- 已知某年某月,请输出这个月共有多少天(switch语句)
- 已知某年某月,请输出这个月共有多少天(if语句)
- [Java]输出某年某月末日有多少天
- 计算这个月有多少天
- 1526:这个月有多少天
- 某年某月多少天函数
- 返回某年某月有多少天
- 得到某年某月有多少天
- 得到某年某月有多少天
- 得到某年某月有多少天
- 1036 某年某月有多少天
- 1036: 某年某月有多少天
- 判断某年某月有多少天
- 如何用JS计算某年某月天数(如2015年2月共有28天)
- 获取一月共有多少天
- 某年某月某日到某年某月某日有多少天
- C#判断某年某月共有多少个周末,分别是哪几天
- C#判断某年某月共有多少个周末,分别是哪几天
- Matlab与线性代数 -- 矩阵的左除
- LFS详细搭建指南——适合初学者使用 (转)
- [Caffe]:关于diff = 0/nan
- 系统回调 CmpCallback
- 02jquery01-05jquery选择器
- 已知某年某月,请输出这个月共有多少天(switch语句)
- javascript获取AJAX对象(DOM方式)
- Vertica的这些事<十五>—— Vertica备份元数据信息
- 自定义View获取dimen值得三个方法:getDimension,getDimensionPixelOffset和getDimensionPixelSize
- 如何使虚拟机VMware workstation连接局域网
- MySQL的安装与卸载
- 隐马尔科夫模型攻略
- 【二分】【前缀和】【数学归纳法】【优化】NOIP模拟测试题"nan"
- 解决开机提示High Severity Error问题