Lab 2 :: Find Day From the Date

In this lab you are asked to write a program (class) which takes date like 17 9 1921 as input from the command line and finds day of the week for this date. For example, output of your program on the above input should be: The date 17 9 1921 is a Saturday.

The basic idea of this program is to remember a standard date day pair (for example: Jan 1, 2003 was a Wednesday), and compute the number of days, between the standard date and the given date, modulo 7. For instance if the date is later than Jan 1, 2003 and the above diff mod 7 is 2 then the given date is Friday. If the date is before Jan 1, 2003 and the above diff mod 7 is 2 then the given date is Monday.

Also remember that a year is a leap year if it is a multiple of 4. An exception to the above is when the year is also a multiple of 100, in that case the year is a leap year iff it is a multiple of 400. For example, 1900 was not a leap year but 2000 was a leap year.

It is easier to accomplish a complex programming task by breaking it into a number of smaller tasks which are easier to code. You are given a file Day_From_Date.java which contains one possible break-up into smaller functions for this problem. Behaviour of these functions (input/output relation) is specified and you have to write the function bodies. In the main method you have to combine these functions to solve the given problem.

Alternatively, you may also use a different approach than the one outlined in Day_From_Date.java file. However, you are not allowed to use system defined classes related to "dates".

If time permits, you may also consider checking validity of the input and outputting appropriate message in the case of invalid inputs. Another possible extension is to draw a table of days and dates for any given month and year.

As this lab is difficult for you to be able to solve this week, you may not write function main in the Day_From_Date class. The other functions in Day_From_Date class can be tested using the following test classes.
Test_leap.java
Test_num_of_leap_years.java
Test_num_of_days.java
Test_days_to_endofmonth.java

These test classes should be invoked with command line arguments corresponding to arguments of the function being tested. Your TAs should be able to explain more details.