Introduction

Reverend Zeller developed a formula for computing the day of the week on which a given date fell or will fall. Suppose that we let a, b, c and d be integers defined as follows:
a = the number of the month of the year, with March = 1, April = 2, and so on, with
January and February being counted as month 11 and 12 of the preceding year
b = the day of the month
c = the year of the century
d = century
For example, July 31, 1929 gives a = 5, b = 31, c = 29, d = 19; January 3, 1988 gives a = 11, b = 3, c = 87, d = 19. Now calculate the following integer quantities:
w = the integer quotient (13a – 1)/5
x = the integer quotient c/4
y = the integer quotient d/4
z = w + x + y + b + c – 2d
r = z reduced modulo 7; that is, r is the remainder of z divided by 7; r = 0 represents
Sunday; r = 1 represents Monday, and so on.


Specific Instructions

Implement a MyDate class to represent a date. The input has to be read as a string using an overloaded input operator. Preferably, no accessor function should be used to set the values of the data members. While reading the specified date, your program should validate the format i.e. while July 31, 1929 would be correct, 7/31/29, July 31, 29, 31/7/29 for example would be incorrect. The MyDate object should be able to find its own day of the week! Write a test program that illustrates the use of your MyDate class. The input to test the program should include the following:
July 31, 1929
January 3, 1988
March 21, 05
December 12, 1960
9/31/2005
July 4, 1776
January 1, 1991

Include all the source code (well documented) and input files and sufficient representative output.

just an off-topic thought though

For example, July 31, 1929 gives a = 5, b = 31, c = 29, d = 19; January 3, 1988 gives a = 11, b = 3, c = 87, d = 19. Now calculate the following integer quantities:

shouldn't the century be 20?

>a formula for computing the day of the week on which a given date fell or will fall.
Wow, deja vu.

These guys need to see your codings first; what you have done so far for the task. THEN, we could you...capiche?

This article has been dead for over six months. Start a new discussion instead.