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;