I need to write a C++ program that can be used to calculate the date of any Easter Sunday which can be computed as follows;
Let X be the year for which it is desired to compute Easter Sunday.
Let A be the remainder of the division of X by 19.
Let B be the remainder of the division of X by 4.
Let C be the remainder of the division of X by 7.
Let D be the remainder of the division of (19*A+24) by 30.
Let E be the remainder of the division of (2*B+4*C+6*D+5) by 7.
Easter Sunday = March 22+D+E. (Note-This can give a date in April)
The program should prompt the user for a year and then calculates and outputs (properly labeled), the correct month, day and year for that year’s Easter Sunday.
I'm understanding the subject a little bit. I think there it should include 'if' and 'else' statements.
See my code I have thus far: I get an error message that says that 'x' has not been assigned a value...But 'x' is what I want to personally enter as 'cin'- the year.
Thanks.
--------------------------------------------------------------------------------
#include "stdafx.h"
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
int main()
{
int x;//The year for which it is desired to compute Easter Sunday.
int a = x % 19;//The remainder of the division of x by 19.
int b = x % 4;//The remainder of the division of x by 4.
int c = x % 7;//The remainder of the division of x by 7.
int d = (19 * a) + (24) % 30;//The remainder of the division of (19*a + 24) by 30.
int e = (2 * b) + (4 * c) + (6 * d) + (5) % 30;//The remainder of the division of (2*b+4*c+6*d+5) by 7.
int sun = (22 + d + e);//The calculation of easter sunday.
cout<< "Enter the year you wish to inquire about"<<endl;
cout<<x<<endl;
cin>> x;//The 4-digit year.
cout<< sun<<endl;
return 0;