java算闰年公式_Java 小日历格式输出 闰年计算

2010-04-26 22:36

import java.util.Scanner;

public class _calendar {

public static void main(String[] args) {

// TODO Auto-generated method stub

System.out.println("请输入年份:");

Scanner sc = new Scanner(System.in);

int year = sc.nextInt();

if (year < 1900) {

System.out.println("请输入大于1900年的年份:");

year = sc.nextInt();

}

System.out.println("请输入月份:");

int month = sc.nextInt();

if (month < 0 || month > 12) {

System.out.println("请输入正确月份(1-12):");

month = sc.nextInt();

}

System.out.println("年份:" + year + ",月份:" + month);

/* 判断是否是闰年 */

boolean y = run_count(year);

System.out.println();

/*

* if((year%4==0)&&(year%100!=0)||(year%400==0)) {

* System.out.println("该年份是闰年!"); y=true; } else { y=false;

* System.out.println("该年份不是闰年!"); }

*/

/* 计算输入月份的天数 */

int day;

day = day_count(y, month);

/*

* { if((y==true)&&(month==2)) { day=29;

* System.out.println("该年月份下,月份:"+day+"天"); } else

* if((y==false)&&(month==2)) { day=28;

* System.out.println("该年月份下,月份:"+day+"天"); } else

* if((month==4)||(month==6)||(month==9)||(month==11)) { day=30;

* System.out.println("该年月份下,月份:"+day+"天"); } else {day=31;

* System.out.println("该年月份下,月份:"+day+"天");}}

*/

/* 计算该月第一天是星期几 */

/* 1、计算输入年份距离1900年1月1日的天数 */

int run = 0;// 输入年份距1900之间有多少闰年

for (int x = 1900; x < year;

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值