求java实现日历记事本

2022-03-24 教育 98阅读
importjava.util.Scanner;publicclassprintCalenderDemo{ publicstaticintyear=Integer.MIN_VALUE; publicstaticintmonth=Integer.MIN_VALUE; publicstaticvoidmain(String[]args){ // intsum=getSomeDaysOfYears();// sum+=getSomeDayOfMonth(); // sum++; //在上个月的最后一天 PrintCalender(); } publicstaticvoidPrintCalender() { InputYearAndMonth(); intsum=getSomeDaysOfYears(); sum+=getSomeDayOfMonth(); sum++; System.out.println("第一天是星期"+sum%7); PrintMonthTitle(); PrintBody(); } privatestaticvoidPrintMonthTitle() { String[]monthNames={"一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"}; System.out.println(year+"\t"+monthNames[month-1]); System.out.println("星期一\t星期二\t星期三\t星期四\t星期五\t星期六\t星期天"); } publicstaticvoidPrintBody() { intsum=getSomeDaysOfYears(); sum+=getSomeDayOfMonth(); sum++; intmonthNumber=MonthNumber(); intblank=sum%7; if(blank==0) blank=; for(inti=1;i=3) sum++; returnsum; } publicstaticintMonthNumber() { int[]dayOfMonth={31,28,31,30,31,30,31,31,30,31,30,31}; intmonthNumber=dayOfMonth[month-1]; if(month==2&&isLeapYear(year)) monthNumber++; returnmonthNumber; } privatestaticbooleanisLeapYear(intyear){ returnyear%400==0||year%4==0&&year%100!=0; } privatestaticvoidInputYearAndMonth(){ Scannerinput=newScanner(System.in); System.out.println("请输入月份和月份:"); year=input.nextInt(); month=input.nextInt(); input.close(); input=null; }}
声明:你问我答网所有作品(图文、音视频)均由用户自行上传分享,仅供网友学习交流。若您的权利被侵害,请联系fangmu6661024@163.com