JAVA万年历程序 能够输出任意月份的日历

import java.util.Scanner;
	public class WanNianLi {

	public static boolean isLeapYear(int year) {
			if((year%4==0&&year%100!=0)||(year%400==0))
			return true;
			else return false;
		}
	public static void main(String[] args) {
		Scanner input=new Scanner(System.in);
		int dom[]= {0,31,28,31,30,31,30,31,31,30,31,30,31};
		int year,month;
		int countDay=0;
		System.out.print("请输入年份(公元):");
		year=input.nextInt();
		if(year<1) {
			System.out.println("输入错误!");
			return;
		}
		System.out.println("请输入月份");
		month=input.nextInt();
		if(month<1||month>12) {
			System.out.println("输入错误!");
			return;
		}
		if(isLeapYear(year)) dom[2]=29;
		for(int numYear=1;numYear
效果如图: JAVA万年历程序 能够输出任意月份的日历_第1张图片

你可能感兴趣的:(JAVA)