I\'m working on a Java assignment and it involves printing a calendar after the user specifies a month and a year. I cannot use the Calendar or GregorianCalendar classes. My pro
I Know you got the answer. But here is quick fix (Sorry its kinda hacky) that you can incorporate to correct your indexes for Saturday without making many changes to your code.
System.out.println("Su Mo Tu We Th Fr Sa");
int xx = h == 0 ? 7 : h; // Correct the index for Saturday.
for (int i = xx; i > 1; i--) // Reversing the loop condition
System.out.print(" ");
for (int i = 1; i <= numDays; i++) {
System.out.printf("%2d ", i);
if (((i + h - 1) % 7 == 0) || (i == numDays))
System.out.println();
}