CS 101 - Introduction to Computing, Spring 2007

Spring 2007

Homework 4 - Creating an HTML Calendar File

Due: Thursday, May 3, 2007 at 11:59 pm

For this assignment, you are to write a JES function called makeCalendar ( ) that will generate the HTML file that will contain the needed code to display a monthly calendar via a web browser.

The calendar for April 2007 would appear as:

April
Sunday Monday Tuesday Wednesday Thursday Friday Saturday
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30

This JES function is to take two integer parameters. The first parameter will indicate which month we wish to display. The second parameter will indicate on which day of the week the first day of the month occurs. For these paratmeter, the months and days are to be represented in the following manner:

Month ValuesDay Values
  1. January
  2. February
  3. March
  4. April
  5. May
  6. June
  7. July
  8. August
  9. September
  10. October
  11. November
  12. December
  1. Sunday
  2. Monday
  3. Tuesday
  4. Wednesday
  5. Thursday
  6. Friday
  7. Saturday

Thus to print out the above calendar for April, the call would be:

     makeCalendar (4, 1)
To print out the calendar for the following May, the parameters values would be 5 and 3 since it would start on a Tuesday.

The month value is used for two things:

  1. To determine the name of the month for the caption at the beginning of the calendar.
  2. To determine the number of days in the month
You will need to somehow put this information in your program that tell you that a month value of 4 gives the name of April and that there are 30 days in the month. Note that we are not worring about the year so February will always have 28 days. See extra credit below if you wish to handle leap years.

Extra Credit

For 5 pts extra credit, you can add a third parameter value that will give a year value. Use this year value to determine if it is a leap year and whether February should have 28 or 29 days. The calculations to determine whether something is a leap year or not is determined by the following: Thus 1600, 2000 and 2400 are leap years but 1700, 1800, 1900 and 2100 are not.

Submitting Your Project

Your code must be commented and written in good programming style. You are to submit your final program to the digital drop box on the CS 101 Blackboard site.