CS 111 - SUMMER 2002: Homework 2

Due Thursday, June 6

Reading: Chapters 3 (second part), pages 182-208 and chapter 4, pages 239-264.


Reminder: Homework is due by 5:00 PM.

The files you must submit for this homework are exactly "calendar.cpp" and "calendar.scr" (containing a script of your source code, compilation, and test runs, in that order).

You are to write 5 of the functions in a calendar program. The program takes as input any four digit year after 1899 and outputs the calendar of that year. To see what it should look like you can try out the UNIX program cal. To do this just type "cal year_no", for example "cal 1977". Your program will do the same thing except that the months will be printed down the page rather than across.

You can find the detailed outline of the program here or in the file ~homer/hw2.cpp on csa.

You will need to write the 5 functions indicated. They are GetYearFromUser, IndentFirstLine, FirstDayOfMonth, MonthDays, and IsLeapYear.

The rule for leap years can be found in homework 1.

Check your program by running it on several different inputs. You should turn in the output from the years 2040 and 1997 (in that order) and one other year.

As a suggestion, give your executable (not to be submitted) a name like "calprog", since "cal" and "calendar" are already commands on the system.


Academic Honesty and Collaboration

It is reasonable to discuss with others possible general approaches to problems. It is unreasonable to work together on a detailed solution, to copy a solution, or to give away a solution. If your common discussion can be detected by looking at the solutions, then there is too much collaboration. Such instances of academic dishonesty will result in a course grade of F or expulsion from Boston University.

Do not allow your work to be used by others:

Warning: If someone cheats by using your work, you will also be penalized


Page Created: May 25, 2002