java 平年闰年的判断,并输出月份天数
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); }}

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) {

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天。");}}}}

声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
阅读量:88
阅读量:47
阅读量:59
阅读量:96
阅读量:31