{ Print the dates of the given month in the given year, with a nice heading. dayFor1st is the day (SUN=0, MON=1, ...) of the first of the month. } procedure PrintMonth (month, year, dayFor1st: integer); { Print the month name, year, and the week heading. } procedure PrintHeading (month, year: integer); begin {PrintHeading} case month of JAN: write ('January '); FEB: write ('February '); MAR: write ('March '); APR: write ('April '); MAY: write ('May '); JUN: write ('June '); JUL: write ('July '); AUG: write ('August '); SEP: write ('September '); OCT: write ('October '); NOV: write ('November '); DEC: write ('December '); end; writeln (year); writeln; writeln (' S M T W T F S'); end {PrintHeading}; { Print the dates of the month in nice calendar form. First print the blanks in the first week, then print the days of the month, adding a carriage return at the end of each week. } procedure PrintDates (dayFor1st, numberDates: integer); var date: integer; begin {PrintDates} if dayFor1st > 0 then begin write (BLANK: dayFor1st * 3); end; for date := 1 to numberDates do begin write (date: 3); if (date + dayFor1st) mod 7 = 0 then begin writeln; end; end; if (numberDates + dayFor1st) mod 7 <> 0 then begin writeln; end; writeln; writeln; end {PrintDates}; begin {PrintMonth} PrintHeading (month, year); PrintDates (dayFor1st, NumberOfDaysIn (month, year)); end {PrintMonth};