输入年月输出该月的天数(Java)

上传人:飞****9 文档编号:131944795 上传时间:2020-05-11 格式:DOC 页数:2 大小:70KB
返回 下载 相关 举报
输入年月输出该月的天数(Java)_第1页
第1页 / 共2页
输入年月输出该月的天数(Java)_第2页
第2页 / 共2页
亲,该文档总共2页,全部预览完了,如果喜欢就下载吧!
资源描述

《输入年月输出该月的天数(Java)》由会员分享,可在线阅读,更多相关《输入年月输出该月的天数(Java)(2页珍藏版)》请在金锄头文库上搜索。

1、package day004;import java.util.Scanner;public class YearAndMonth public static void main(String args)Scanner scanner = new Scanner(System.in);System.out.println(请输入年份(例如:2000));int year = scanner.nextInt();System.out.println(请输入月份(例如:1));int month = scanner.nextInt();scanner.close();switch(month)ca

2、se 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天);elseSystem.out.println(year + 年 + month + 月有28天);break;

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > IT计算机/网络 > 其它相关文档

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号