当前位置:首页 » 编程软件 » 判月编程

判月编程

发布时间: 2023-08-27 21:59:17

java编程 判断月份,判断天数

importjava.util.*;
/**
*
*这里没有对输入非数字的数进行处理!
*/
publicclassShell{
publicstaticvoidmain(String[]args){
Scannersc=newScanner(System.in);
inty=0;
intn=0;
//输入年份,用于判断闰年!
System.out.println("请输入年份:");
y=sc.nextInt();
System.out.println("请输入月份:");
n=sc.nextInt();
switch(n){
case1:
case3:
case5:
case7:
case8:
case10:
case12:
System.out.println(n+"月份有:31天");
break;
//对于2月份需要判断是否为闰年
case2:
if((y%4==0&&y%100!=0)||(y%400==0)){
System.out.println(n+"月份有:29天");
break;
}else{
System.out.println(n+"月份有:28天");
break;
}
case4:
case6:
case9:
case11:
System.out.println(n+"月份有:30天");
break;
default:
System.out.println("请输入正确的年份和月份");
break;
}
}
}

热点内容
linuxisthisok 发布:2025-07-13 14:12:13 浏览:160
sql查询分析器下载 发布:2025-07-13 14:07:45 浏览:52
怎么设置网络与计算机配置同步 发布:2025-07-13 14:01:39 浏览:449
jsp查询数据库显示 发布:2025-07-13 14:01:37 浏览:190
winrar解压慢 发布:2025-07-13 13:57:26 浏览:741
我的世界新手区服务器 发布:2025-07-13 13:50:52 浏览:953
M视频压缩 发布:2025-07-13 13:50:04 浏览:210
润享wifi密码是多少 发布:2025-07-13 13:49:48 浏览:612
九宫格抽奖源码 发布:2025-07-13 13:48:11 浏览:762
androidzip安装 发布:2025-07-13 13:35:24 浏览:10