Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Complete the printMonth(int numDays, int startDay) method below to print a calen

ID: 3542630 • Letter: C

Question

Complete the printMonth(int numDays, int startDay) method below to print a calendar month. The

parameters numDays and startDay indicate how many days are in the month, and which day of the week

the month starts on (Sunday==0, Monday==1, etc.). Make sure that the printout lines up vertically. For

example, calling printMonth(31, 3) should result in printing:

Su Mo Tu We Th Fr Sa

                    1    2   3   4

5    6    7    8    9  10 11

12  13  14  15 16 17 18

19  20   21 22  23 24 25

26  27   28 29  30 31

public static void printMonth(int numDays, int startDays)

{







}

Explanation / Answer

public class printer
{
public static void printMonth(int numDays, int startDays)
{
System.out.printf("Su Mo Tu We Th Fr Sa ");
for(int i=0; i<startDays; i++)
System.out.printf("    ");
for(int i=1; i<=numDays; i++)
{
System.out.printf("%2d ",i);
if((i+startDays)%7==0)System.out.println();
}
}
public static void main(String[] args)
{
printMonth(31,3);
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote