public class Test14 { public static void main(String[] args) { /* 1.打印指定月份的日历信息(实现从键盘输入1900年之后的任意的某年、某月,输出该月的日历) 如下:2020年8月 星期日 星期一 星期二 星期三 星期四 星期五 星期六 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 .... */ Scanner sc=new Scanner(System.in); System.out.println("请输入年份"); int year= sc.nextInt(); System.out.println("请输入月份"); int mouth=sc.nextInt(); printDay(year, mouth); } //打印日历 public static void printDay(int year,int month){ //打印title System.out.println("星期日\t星期一\t星期二\t星期三\t星期四\t星期五\t星期六"); //在当月的1号前面打印空格 int weekDay = getWeekDay(year , month); for (int i = 0; i <weekDay; i++){ System.out.print("\t\t"); } //打印日历 int monthDay = getMonthD
java打印日历
最新推荐文章于 2024-09-21 15:47:50 发布