Engr 123 Assignment 2 Day of the Week January 20, 2016 Due: January 27, 2016 Charles Dodgson, aka Lewis Carroll of Alice in Wonderland fame, was a mathematician who taught at Oxford in the 19th century. He published an algorithm which allows a user to determine the day of the week for any given date. His algorithm is given below. A given date has four parts: the century, the year, the month, and the date. Each of these four items is processed separately to form a number. When the numbers are added the sum modulo seven provides the day of the week of the date with Sunday = 0, Monday =1, etc. Century number: The century number is 2 x (3 - century mod 4). For example, if the date is January 21, 2009, the century is 20 so 2 x (3 – 20%4) = 6. Year number: The year number is ((int) year/12) + (year mod 12) + (int)((year mod 12) /4). For example if the date is January 21, 2009 the year is 9 so (int)9/12 + 9%12 + (int)(9%12)/4) = 0 + 9 + 2 = 11. Month number: The month number is given by the following table: Month Num Month January 0 July February 3 August March 3 September April 6 October May 8 November June 4 December For the date January 21, 2009 the month number is 0. Num 6 2 5 0 3 12 Date number: The day number is the day of the month. For example, if the date is January 21, 2009 the day number is 21. Leap Year Correction: All years that are evenly divisible by 400 or, are evenly divisible by 4 and not evenly divisible by 100 are leap years. So that 2000 is evenly divisible by 400 so it is a leap year. The year 2004 is evenly divisible by 4 and it is not evenly divisible by 100 so it is also a leap year. If the month is January or February in a leap year you must subtract 1 from the total unless the total is 0 in which case you must add 6. For the date January 21, 2009, the year is not a leap year so no correction is necessary. The total of the four numbers is 6 + 11 + 0 + 21 = 38. 38 % 7 = 3 so the day is Wednesday. More examples: March 31, 2009 The century number is 2 x (3 - century mod 4). The century is 20 so 2 x (3 – 20%4) = 6. The year number is ((int) year/12) + (year mod 12) + (int)((year mod 12) /4). So (int)9/12 + 9%12 + (int)(9%12)/4) = 0 + 9 + 2 = 11. The month number is 3 from the table. The day number is 31. The total is 6 + 11 + 3 + 31 = 51 51%7 = 2 so Tuesday December 25, 2008 The century number is 2 x (3 - century mod 4). The century is 20 so 2 x (3 – 20%4) = 6. The year number is ((int) year/12) + (year mod 12) + (int)((year mod 12) /4). So (int)8/12 + 8%12 + (int)(8%12)/4) = 0 + 8 + 2 = 10. The month number is 12 from the table. The day number is 25. The total is 6 + 10 + 12 + 25 = 53 53 % 7 = 4 so Thursday September 18, 1783 The century number is 2 x (3 - century mod 4). The century is 17 so 2 x (3 – 17%4) = 4. The year number is ((int) year/12) + (year mod 12) + (int)((year mod 12) /4). So (int)83/12 + 83%12 + (int)(83%12)/4) = 6 + 11 + 2 = 19. The month number is 5 from the table. The day number is 18. The total is 4 + 19 + 5 + 18 = 46, 46 % 7 = 4 so Thursday Write a console application in C# which will print the day of the week in response to the entry of a date. Your date may be entered on three lines using three prompts to the user. A typical output for your program is shown below: Note that the program continues to prompt the user for dates until the user enters the word "Done" for the month. Enter the month: December Enter the day of the month: 25 Enter the year: 2008 The day for December 25, 2008 is Thursday. Enter the month: Done After you get your program running correctly, place a copy of the design into the project folder as a doc or docx file. Right click on the project folder and choose Send To → Compressed zip file. Rename the compressed zip file as Asn02XXX.zip where XXX are you three initials. Upload the renamed file to \\cecsfp01\users\everyone\engr123.