PROGRAM SetOperations(Output);
    { program 8.2 - Illustrate set operations. }

    TYPE
        Days = (Mon, Tue, Wed, Thu, Fri, Sat, Sun);
        Week = SET OF Days;
    VAR
        FullWeek, Work, Free: Week;
        Day: Days;

    PROCEDURE Check(W: Week); { procedures are introduced in chapter 11 }
    VAR
        D: Days;
    BEGIN
        FOR D := Mon TO Sun DO
            IF D IN W THEN
                Write(Output, 'X')
            ELSE
                Write(Output, 'O');
            WriteLn(Output);
    END;    { Check }

BEGIN
    Work := [];
    Free := [];
    FullWeek := [Mon..Sun];

    Day := Sat;
    Free := [Day] + Free + [Sun];
    Check(Free);

    Work := FullWeek - Free;
    Check(Work);

    IF Free <= FullWeek THEN
        Write(Output, 'O');
    IF FullWeek >= Work THEN
        Write(Output, 'K');
    IF NOT (Work >= Free) THEN
        Write(Output, ' Jack');
    IF [Sat] <= Work THEN
        Write(Output, ' Forget it!');
    WriteLn(Output);
END.
