package com.company;
import java.util.Calendar;
import java.util.Scanner;
public class calendardate {
public static void main(String[] args) {
System.out.println("请输入年份");
Scanner scanner = new Scanner(System.in);
int year = scanner.nextInt();
System.out.println("请输入月份");
int month = scanner.nextInt();
System.out.println("请输入日期");
int date = scanner.nextInt();
Calendar calendar = Calendar.getInstance();
calendar.set(year,month-1,1);
int day = calendar.getActualMaximum(Calendar.DATE);
int xday = calendar.get(Calendar.DAY_OF_WEEK);
System.out.println(xday);
System.out.println("日\t一\t二\t三\t四\t五\t六");
int index = 1;
for (int i = 0;i<day+xday-1;i++){
if (i<xday-1){
System.out.print("\t");
}
else {
if (date == index){
System.out.print(index+"*"+"\t");
}else {
System.out.print(index+"\t");
}
if ((i+1)%7 == 0){
System.out.println();
}
index++;
}
}
}
}
网友评论