Sections 0101, 0102, 0103 and Honors, Fall 1995
Thursday October 12, 1995
Assigned Reading: 5.6
Handouts (available on-line): none
Topics Covered:
- The calendar program. We discussed many aspects of Top-Down design
(also known as "stepwise refinement") with regards to the calendar
program. Then we developed the program in steps.
- Step 1 is a small loop that prints the calendar for
one month, given the number of days in the month and
the weekday of the first day of the month.
See program and
sample run.
- Step 2 is another small program that uses a function to
determine the weekday of a day x days after a certain weekday.
(E.g., what is the weekday of the day that is 365 days after
a Monday?) See program and
sample run.
- Step 3 puts Step 1 and Step 2 together as a "trial test".
We print the calendars for several months in a row, assuming
all months have 31 days. It's not what we want in the final
program, but we can check if our strategy works.
See program and
sample run.
- In step 4, we steal some functions from
the textbook's calendar program to compute the number of
days in a given month and the number of days in a given year.
See program and
sample run.
- Step 5 puts it all together and now we have our own version
of the calendar program that is somewhat different from the
textbook's version. Both work, but we got to experience how
we might put a larger program together.
See program and
sample run.
Last Modified:
Fri Oct 13 14:52:58 EDT 1995
Richard Chang, chang@gl.umbc.edu