Search for question

Zeller's Congruence is a formula that calculates the day of the week on which any date falls, given the month, day, and year. Zeller's Congruence is:

(D+ (M+1)*26/10 + Y + Y/4 + C/4 - 2*C) % 7

where C is the century (the left-most two digits of the year, for example, 19 if the year is 1948), Y is the year within the century (0-99), D is the day number (1-31), and M is de- termined from the month as follows:

Assignment

Write a C++ function called weekday that uses Zeller's Congruence to calculate the day of the week on which a chosen date falls. The arguments of the function are three integers that indicate the chosen month (1-12), day (1-31), and year, for example, 3, 28, and 2022 for March 28, 2022. The return value of the function is an integer in the range 0-6 to indi- cate the weekday on which the date falls. Input dates from an input file. Output weekdays to an output file.

Fig: 1

Fig: 2