program Calendar; {Reads the day of January 1 and the year and prints calendar. Demo for stubs, drivers, and enumerated types.} type DayType = (Sun, Mon, Tue, Wed, Thur, Fri, Sat); WeekdayType = Mon..Fri; MonthType = (Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec); YearType = 1500..2500; {valid for Gregorian calendar} var Year : Yeartype; {input - the calendar year} StartDay : Daytype; {input - New Year's Day} DayCh1,DayCh2,DayCh3 : Char; {input - letters in day name} Month : MonthType; {the current month} FebFlag : Boolean; {true for leap years} function LeapYear(YearFP : YearType) : Boolean; {determine if leap year; details needed} begin LeapYear := YearFP mod 4 = 0; if ((YearFp mod 100) = 0)) and ((YearFP mod 400) <> 0) then LeapYear := False; end; procedure Heading(YearFP : YearType); {stub - to output nice heading} begin WriteLn('Heading for year ', YearFP); end; procedure DayCode(Ch1,Ch2: Char; var Day : DayType); {stub of day conversion - returns Sun or Mon} begin case Ch1 of 'S' : Day := Sun else Day := Mon end{case Ch1}; end; procedure PrintMonth(Month: MonthType; var StDay : DayType); {the main procedure} var ML : 28..31; begin {MonthHeading(Month); ML := MonLen(Month); PrintWeeks(ML, StDay)} end; begin{main program} WriteLn('Type the year - after 1500, before 2500 - and New Year''s Day'); WriteLn('Use the first 3 letters to identify the day.'); ReadLn(Year, DayCh1, DayCh2, DayCh3); if LeapYear(Year) then FebFlag := True else FebFlag := False; Heading( Year ); DayCode(DayCh1,DayCh2,StartDay); for Month := Jan to Dec do PrintMonth(Month,StartDay); end.