Question: Easter Calculation Our current calendar system is based upon the Gregorian calendar, which took effect in 1583. Calculating the date of Easter each year is
Easter Calculation
Our current calendar system is based upon the Gregorian calendar, which took effect in 1583.
Calculating the date of Easter each year is a difficult exercise. In 1876, the following algorithm for calculating the date of Easter was proposed. Samuel Butcher, the Bishop of Meade, later demonstrated that this algorithm is accurate.
a = year % 19
b = year / 100
c = year % 100
d = b / 4
e = b % 4
f = (b + 8) / 25
g = (b - f + 1) / 3
h = ((19 * a) + b - d - g + 15) % 30
i = c / 4
j = c % 4
k = (32 + (2 * e) + (2 * i) - h - j) % 7
m = (a + (11 * h) + (22 * k) ) / 451
Easter Month = ( h + k - (7 * m) + 114 ) / 31 // where 3 means the month of March and 4 means April
p = ( h + k - (7 * m) + 114 ) % 31 Easter Date = p + 1 In the above calculations, "/" is the integer-division operator, which returns the integer result of the division operation (quotient); "%" is the modulus operator, which returns the integer remainder. Both operands passed to the integer-division and the modulus operators must be integers.
Here's an example:
9 \ 5 = 1
9 % 5 = 4
The order of operations (or operator precedence) is a set of rules defining which operations to perform first when evaluating a given mathematical expression. For example, the rules of operator precedence dictate that the multiplication operator ("*") is evaluated before the addition operator ("+"). Parentheses inserted into an expression can override the natural order of precedence.
Write a C++ program that prompts for the year and then calculates the date of Easter. A sample program dialog is shown below.
What's the year: 2006 Easter Month is April Easter Day is 16 What's the year: 2005 Easter Month is March Easter Day is 27
What's the year: 2004 Easter Month is April Easter Day is 11 HINT: You might try building these calculations inside MS Excel and then do them step-by-step verifying the values calculated in your program against your spreadsheet answers.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
