5. What Day Were You Born On? Write a program that will determine the day of the week that someone was born on, based on his or her numerical birth date. The input is the numerical month, day and two-digit year (in 1900’s) and the program will use the algorithm below to find the day of the week they were born.
1. Let the month, date and year be m, d and y respectively
2. Let A = y + y / 4
3. Let B = A % 7
4. Let C = B + d
5. Let E = C + Month Code (based on m, as shown in table)
m |
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
Code |
1 |
4 |
4 |
0 |
2 |
5 |
0 |
3 |
6 |
1 |
4 |
6 |
6. Let F = E % 7
7. If F=0 then Day = Saturday, F=1 (Sunday), F=2 (Monday), etc…
Note: There is one exception to this algorithm. If a person is born in January or February of a leap year, you need to subtract 1 from E before going to step 6. Leap years are those years evenly divisible by 4, such as 1988 or 2004.
Your task: write a program that reads names and birth dates from a file called birthday.txt stored in the txtfiles folder on the H drive.
The data will be stored in the following format:
Bob Douglas
9 15 86
Andrew Tai
2 6 86
etc…
Output the results as follows:
Bob Douglas was born on a Tuesday.
Andrew Tai was born on a Thursday.
etc… |