< previous page page_384 next page >

Page 384
the week on which a month starts and the number of days in the month. Each successive month starts on the day of the week that follows the last day of the preceding month. Days of the week should be numbered 0 through 6 for Sunday through Saturday. Years that are divisible by 4 are leap years. (Determining leap years actually is more complicated than this, but for this program it will suffice.) Here is a sample run for an interactive program:
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
What year do you want a calendar for?
2002
What day of the week does January 1 fall on?
(Enter 0 for Sunday, 1 for Monday, etc.)
2
         2002

      January
 S  M  T  W  T  F  S
____________________
       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

    February
 S  M  T  W  T  F  S
____________________
                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
         .
         .
         .

       December
 S  M  T  W  T  F  S
____________________
 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
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
When writing your program, be sure to use proper indentation and style, meaningful identifiers, and plenty of comments.

 
< previous page page_384 next page >