School of Engineering and Applied Science
Department of Computer Science
CSci 53 -- Introduction to Software Development
http://www.seas.gwu.edu/~csci53/fall02
Prof. Michael B. Feldman
mfeldman@seas.gwu.edu

Project 4
Due Date: beginning of lecture, Thursday, Oct. 17, 2002

The purpose of this assignment is to become familiar with conditional control structures.

Background

A calendar date consists of a month, a day of the month, and a year. Many programs must be able to handle dates, so it is useful to understand how such things are represented and manipulated.

In this project, we will represent a date as an ordered triple of integer values representing the month, day, and year, in that order. To be a valid date, this triple must have four properties:

  1. the month must be in the range 1-12, where January = 1 and December = 12;
  2. the day must be in the range 1-31;
  3. the year must be no earlier than 1753, the first full year of our current (Gregorian) calendar;
  4. the month/day/year combination must form a valid date; that is, 
A year is a leap year if it is divisible by 4 but not by 100.  Exceptionally, a year that's divisible by 400 is a leap year. (ASIDE: one aspect of the "Y2K problem" of the year 2000 is that many programs failed to recognize this exception, and treated 2000 as a non-leap year!)

Project

Develop a program that will
To find the day of the week, you can import the class csci53.DateOps, which contains the following method. A program that demonstrates this is DayTest.java. You can copy both from programs53 into your csci53 directory.
 
  // -----------------------------------------------------------
  // Finds the day of the week for a given date.
  // Sunday = 0, Monday = 1, etc.
  //
  // Assumes its arguments are valid and form a valid date.
  // Calculates correct results for dates in the Gregorian
  // calendar, after September 1752.
  //
  // This code is adapted from a C version that appears at
  //   http://www.eskimo.com/~scs/C-faq/q20.31.html
  //
  // The algorithm is a table-driven adaptation of the famous
  // Zeller Congruence; for more details, see
  //   http://www.merlyn.demon.co.uk/zeller-c.htm
  // -----------------------------------------------------------
  public static int dayOfWeek(int month, int day, int year)


This method returns a numerical value for the day. Your program will have to determine which day name to display as a string.

Use if statements for the date validation and a switch statement for displaying the day name.

What to submit:

You must follow the process given in Systematic Software Development and the sample project packet distributed in class.

Your grade will be calculated on a 20-point basis, as follows:

Extra credit:

We'll continue the 2-point bonus for getting an early start. If you e-mail your "framework" listing file to Prof. Feldman, and the time stamp on the e-mail is no later than 5 PM, Monday, Oct. 14, 2002, you will be awarded 2 extra project points. The "framework" must be a listing (.lis) file, with no compilation errors or warnings, that contains the declared variables, and a set of comments inserted for the main algorithm steps.

MBF 10/2/02