Assignment 8

due at 6pm on Wed 2 Nov

This program will use loops to print a simple calendar. It begins by asking the user how many days in the month, and the start day (so we don’t have to figure that out from the month and year).

Here are some sample runs:

Month with 30 days, starting on Thursday

Enter number of days in month: 30
Enter start day (0=Sun, 1=Mon, ..., 6=Sat): 4
 Sun Mon Tue Wed Thu Fri Sat
                   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

Month with 31 days, starting on Sunday

Enter number of days in month: 31
Enter start day (0=Sun, 1=Mon, ..., 6=Sat): 0
 Sun Mon Tue Wed Thu Fri Sat
   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

Month with 28 days, starting on Saturday

Enter number of days in month: 28
Enter start day (0=Sun, 1=Mon, ..., 6=Sat): 6
 Sun Mon Tue Wed Thu Fri Sat
                           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

©2011 Christopher League · some rights reserved · CC by-sa