Question
C++ Given the year inputted by the user, calculate the month and day of Easter Sunday. When the program executes, it should produce output similar
C++
Given the year inputted by the user, calculate the month and day of Easter Sunday. When the
program executes, it should produce output similar to this.
Easter Sunday Calculator
Enter the year: 1985
Easter Sunday is April 7, 1985
The formula is a complex one and produces the correct day for any year from 1900 through 2099. I have broken it down into intermediate steps as follows. Frequently, Easter Sunday is in March, but occasionally it is in April. The following formula calculates the day of the month in March of Easter Sunday.
let a = year % 19
let b = year % 4
let c = year % 7
now start to put these pieces together
let d = (19 * a + 24) % 30
let e = (2 * b + 4 * c + 6 * d + 5) % 7
finally, the day of the month of Easter Sunday is
let day = 22 + d + e
However, if the day is greater than 31, then subtract 31 days and the resulting value in day is in
April instead. But the equation is off by exactly 7 days if these years are used: 1954, 1981, 2049
and 2076. Thus, when the calculation is finished, if the year is one of these four, you must
subtract 7 days from the day variable. The subtraction does not cause a change in the month.
Test your program on the following years I have shown the day you should obtain in parentheses:
1985 (April 7)
1999 (April 4)
1964 (March 29)
2099 (April 12)
1900 (April 15)
1954 (April 18)
1981 (April 19)
2049 (April 18)
2076 (April 19)
1967 (March 26)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started