master
Chloe Fontenot 🏳️‍⚧️ 2022-10-17 10:24:02 +07:00
parent 9b95ecb4c3
commit 01b7f65e7d
1 changed files with 7 additions and 6 deletions

@ -21,7 +21,7 @@ public class Calendar {
int startDay = firstDay;
int numberOfDaysInMonth = 0;
for (int month = 1; month <= 12; month++) {
System.out.print(" ");
System.out.print(" ");
switch (month) {
case 1: System.out.println("January " + year); numberOfDaysInMonth = 31; break;
case 2: System.out.println("February " + year);
@ -39,19 +39,20 @@ public class Calendar {
case 11: System.out.println("November " + year); numberOfDaysInMonth = 30; break;
case 12: System.out.println("December " + year); numberOfDaysInMonth = 31; break;
}
System.out.println("-----------------------------");
System.out.println("------------------------------------------");
System.out.println(" Sun Mon Tue Wed Thu Fri Sat");
int i = 0;
for (i = 0; i < startDay; i++) {
System.out.print(" ");
System.out.print(" ");
}
for (i = 1; i <= numberOfDaysInMonth; i++)
if (i < 10) System.out.print(" " + 1);
else System.out.print(" " + 1);
for (i = 1; i <= numberOfDaysInMonth; i++) {
if (i < 10) System.out.print(" " + i);
else System.out.print(" " + i);
if ((i + startDay) % 7 == 0) {
System.out.println();
}
}
System.out.println();
System.out.println();
startDay = (startDay + numberOfDaysInMonth) % 7;