One method for computing the day of week of a calendar date is known as the Zeller's congruence, devised by German mathematician Christian Zeller (1822-1899). For those interested in the (math-heavy) derivation of his formula, you can see te Wikipedia article, Zeller's congruence. However, all the of the information that you will need for this project is presented below as well.

Zeller's congruence is a straight-forward mathematical formula, but there is one important point that you must be aware of. Zeller recognized that the leap day of February 29th would complicate the calculation since it falls in the middle of the year. To simplify things, he "moved" the leap day to the end of the year by treating January and February not as the first and second months of year Y, but as the 13th and 14th month of the year Y - 1. For example, if you wanted to find the day of the week for February 2nd, 2009, you would need to perform the calculation for the 2nd day of the 14th month of the year 2008.

The following is the first part of Zeller's congruence: See image.

where

• d is the day of the month,
• Mz is the month, modified to put January and February at the end of the year (3 = March, 4 = April, ..., 12 = December, 13 = January, 14 = February),
• Yz is the year, modified by subtracting 1 if the month was January or February,
• and Z is the result so far.

The [] symbols are the mathematical "floor" function; it means round down whatever is inside them to the nearest integer. In C++, you can compute [x] calling the function floor(x).

Once you have the value Z above, you can convert it to a number tha represents the day of the week with the following formula:

w = ((Z + 5) mode 7) + 12

where W will equal 1 for Monday, 2 for Tuesday, and so on, up to 7 for Sunday. Remember that mod is the remainder after division, represented in c++ by the % operator. (For those curious, this particular numbering system corresponds to the ISO 8601 standard for date/time data, but you don't have to know this.)

This program is designed to be run interactively; the user should be prompted to enter a date as three numbers (the month, the day, and the 4-digit year, in that order) separated by spaces, and then they will hit Enter to see a message showing the day of the week. The following is an example of what you might see when you run the program; input that you type will be shown in green (press Enter at the end of a line), and the output generated by the program shown in black. See image.

Notice that the dates you input should be in proper form (January is the first month, and so on), not in the modified form that Zeller's congruence requires.

Also notice that your program should ask whether another date will be entered. If the response to the prompt is "y" your program will ask for another date, if the user inputs a "n" the program will stop. At this point you don't have to worry about incorrect input, when asked "Would you like to enter another date(y/n): ".

Additionally, your program should be able to calculate an arbitrary number of dates. In the example above there were only 2 dates calculated, but I should be able to ask for 10, 20, 50 etc, dates during the course of running your program with out issue.

Feel free to modify the prompt or the output to personalize it. But since it's being auto-graded, make sure you follow a few simple guidelines:

• The date must be entered in the order "month day year", separated by spaces. This makes it easier to read the date as three easy easy extractions from cin.
• The program should let the user enter one date, print the day of the week, and then prompt whether to process additional dates.
• If you modify the output of the program in any way, make sure that only one day of the week shows up, ever, in the output. What this means is, do not write a prompt to say something like "This program will tell you the day of the week, Monday through Friday".