# Problem!

• 10-03-2001
Nate2430
Problem!
I am doing a project that has the user input any year ranging from 1900 to 2099 and it will display what year easter sunday was on. The equation I have works for every year except 1954, 1981, 2049, 2076. Now my code works for every other year excpet these. I always get the day for these years to come up seven days ahead of what it should. Could someone look at my code and see if they can find a problem.

#include <iostream>
#include <math.h>
#include <iomanip.h>

int main()
{
int year;

cout << "Easter Sunday Calculator" << endl;
cout << "Enter the year: ";
cin >> year;

int a = year % 19;
int b = year % 4;
int c = year % 7;
int d = ( 19 % ( a + 24 ) ) % 30;
int e = ( 2 * ( b + 4 ) * ( c + 6 ) * ( d + 5 ) ) % 7;
int day = 22 + d + e;

if ( ( day <= 31 ) && ( year != 1954, 1981, 2049, 2076 ) )
{
cout << "March " << day << endl;
}
else if ( ( day > 31 ) && ( year != 1954, 1981, 2049, 2076 ) )
{
day = day - 31;
cout << "April " << day << endl;
}
else
{
day = day - 38;
cout << "April " << day << endl;
}
return 0;
}
• 10-04-2001
Carlos
Don't have time to search the bug, but click
here for a general solution.

Lots of algorythms, you'll find here everything you need.
Pretty complicate, though, but it's well-explained.

Have fun!
• 10-04-2001
zoo
Try this:

if ( ( day <= 31 ) && ( year != 1954 && year != 1981 && year != 2049 && year != 2076 ) )
{
cout << "March " << day << endl;
}
else if ( ( day > 31 ) && ( year != 1954 && year != 1981 && year != 2049 && year != 2076 ) )
• 10-05-2001
Carlos
Well, zoo, I think Nate was using just an abbreviation here,
(year != 1954, 1981, 2049, 2076), such code won't compile at all :D. So, not that's the real problem here, I guess.
• 10-05-2001
zoo
Carlos, actually such code will compile. Give it a try.

Regards,
zoo