CMSC 106 HOMEWORK ASSIGNMENT #2
DUE: January 12, 1998 (start of class)
- Design and code a program which takes a packed date as input,
converts the date to unpacked form, determines the previous date,
converts it back to packed form and then prints out the new
date in both forms.
- NB: A twentieth-century date can be written with integers in the
form day/month/year. An example is 1/7/33, which represents
1 July 1933. "Packing" stores the date compactly. Since we need 31
different values for the day, 12 for the month and 100 different value
for the year, we can use 5 bits to represent the day, 4 bits to represent
the month and 7 bits to represent the year. Your functions should be
able to convert between the 3 integer (year, month, day) and 1 16-bit
integer (and vice versa) representations.
- Document the code. Comments should be brief but informative. A good
rule of thumb is a comment for each function. Also a header comment
with your name, social security number, the assignment number,
a general description of the program and the names of any files
in your account needed to execute the program.
- Execute the code (at least four times) using the "script" command to
retain the runs. Make sure at least one of the runs is an interesting
example (e.g. change month/year, leap year).
- Hand in a print-out of the documented code along with the runs.