java 平年闰年的判断,并输出月份天数

 时间:2024-10-14 22:00:39

1、package zixi_3;pu水瑞侮瑜blic class l2 { public static void main(String[] args) { //int i=2000; //if(i%4==0&&i%100==0||i%400==0){System.out.println(i+"是闰年");} //else{System.out.println(i+"是平年");} int i=2001; String str=(i%4==0&&i%100==0||i%400==0)?"闰年":"平年"; System.out.println(i+str); }}

java 平年闰年的判断,并输出月份天数

2、//int i=2000;//if(i%4==0&&i%100==0||i%400==0){System.out.println(i+"是闰年");}//else{System.out.println(i+"是平年");}这是第二种方法,判断。

java 平年闰年的判断,并输出月份天数

3、public class lian3 { public static void main(String[] args) { int year = 2017; int month = 7; if (year % 4 == 0 && year % 100 == 0 || year % 400 == 0) {

java 平年闰年的判断,并输出月份天数

4、System.out.println(year + "是闰年&孥恶膈茯quot;);} else {System.out.println(year + "是平年");}if (month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12) {System.out.println(month + "月份有31天。");} else if (month == 4 || month == 6 || month == 9 || month == 11) {

java 平年闰年的判断,并输出月份天数

5、System.out.println(month + "月份有30天。");} else if (month == 2) {if (year % 4 == 0 && year % 100 == 0 || year % 400 == 0) {System.out.println(month + "月份有29天。");}else {System.out.println(month + "月份有28天。");}}}}

java 平年闰年的判断,并输出月份天数

6、给定年份和月份,判断该月下有多少天。首先判断平年闰年,输出。然后把月份分成三部分,1,3,5,7,8,10,12为31天,2月份两种情况,嵌套if语句。即可

java 平年闰年的判断,并输出月份天数
  • 设计模式:C#如何实现单例模式
  • SQL Server 2005如何建表?
  • 怎样在Authorware中输入中文
  • unity 2018 如何使用VS调试功能
  • winform绘图之OnPaint事件
  • 热门搜索
    关于数学知识的手抄报 万圣节手抄报英语 励志手抄报图片 遵纪守法手抄报内容 有关食品安全的手抄报 古诗手抄报版面设计 小学生防火手抄报 争做文明使者手抄报 语文手抄报五年级 手抄报装饰简单又漂亮