IUP Computer Science
CO 110 Spring 2000

Project #3
(Due 5 pm 3 March 2000)

Two holidays that are somewhat irregular in terms of when they occur are Easter and Thanksgiving. Easter may occur on any date between March 22 and April 25; and Thanksgiving may occur on any date between November 22 and November 28. You are to write a C++ program that can determine on which dates Easter and Thanksgiving occur in any year between 1900 and 2099.

Your textbook gives you the necessary algorithm to determine when Easter occurs on page 168. It says that if you calculate a, b, c, d, and e for the given year as follows, then Easter Sunday will occur on March 22+d+e

     a is year % 19
     b is year % 4
     c is year % 7
     d is (19 * a + 24) % 30
     e is (2 * b + 4 * c + 6 * d + 5) % 7
Of course, if the calculated value of 22+d+e is greater than 31, Easter is really in April (on April 22+d+e-31 or April d+e-9).

On page 169, your textbook notes that there are four years in the range (1900-2099) for which this calculation is off by one week. For the years 1954, 1981, 2049, and 2076, the algorithm produces a result that is 7 days later than it should be. Your program should be able to adjust for this.

Once you know when Easter is (and it is always on a Sunday), your program should be able to determine when Thanksgiving is. Simply determine how many days it is from Easter to May 1. It is 184 days additional days from May 1 to November 1. By determining the number of days from Easter to November 1, the program should be able to determine which day of the week November 1 occurs on. This is all the program should need to determine Thanksgiving's date because Thanksgiving is always the fourth Thursday in November. When November 1 is on a Sunday, Thanksgiving is on November 26; when November 1 is on a Monday, Thanksgiving is on November 25 and so on.

Your program should repeatedly prompt the person at the keyboard for a year and respond by displaying the dates for Easter and Thanksgiving in that year. The program should correctly handle every year between 1900 and 2099. If the person at the keyboard enters a year outside this range, the program should terminate.

Hand in a printout of your program produced by the development environment and a printout from the results window when the following years are entered: 1940, 1978, 1981, 1985, 2001, 2020, and 2049.

There are several ways you may need to try to print the results window. One way to print is with the "Print Screen" key - Hold down the shift key and press Print Screen; this may not output because there is no form feed at the end of the results window. Or you may copy the entire window to the clipboard (hold down Alt and press Print Screen); then, paste it into a document, such as an MS Word document and print. Or mark and copy the contents of the window to the clipboard, then paste it into a wordprocessor document (even Note Pad can accept this) and print.

Here are a few answers so you can determine whether your program is working properly. You can also check this year (or last).
Year           Easter              Thanksgiving
1978           March 26            November 23
1985           April 7             November 28
2049           April 18            November 25