Hello I was wondering if anyone could help me with this prog
Hello I was wondering if anyone could help me with this programming assignment in C++. Thanks in advance! : 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.
Solution
#include <iostream>
using namespace std;
string get_month_name( int index )
{
switch (index)
{
case 1:
return \"January\";
case 2:
return \"February\";
case 3:
return \"March\";
case 4:
return \"April\";
case 5:
return \"May\";
case 6:
return \"June\";
case 7:
return \"July\";
case 8:
return \"August\";
case 9:
return \"September\";
case 10:
return \"October\";
case 11:
return \"November\";
case 12:
return \"December\";
}
}
int main()
{
int year;
cout << \"What\'s the year: \" ;
cin >> year;
int a = year % 19;
int b = year / 100;
int c = year % 100;
int d = b / 4;
int e = b % 4;
int f = (b + 8) / 25;
int g = (b - f + 1) / 3;
int h = ((19 * a) + b - d - g + 15) % 30;
int i = c / 4;
int j = c % 4;
int k = (32 + (2 * e) + (2 * i) - h - j) % 7;
int m = (a + (11 * h) + (22 * k) ) / 451;
int easter_month = ( h + k - (7 * m) + 114 ) / 31; // where 3 means the month of March and 4 means April
int p = ( h + k - (7 * m) + 114 ) % 31;
int easter_date = p + 1;
cout << \"Easter Month is \" << get_month_name(easter_month) << endl;
cout << \"Easter Day is \" << easter_date << endl;
return 0;
}


