zandiago 115 Nearly a Posting Maven Featured Poster

Ok..got it-it works now: So far I have:

#include "stdafx.h"
#include <iostream>
#include <string>
#include <cmath>
#include <time.h>
#include <stdio.h>
#include <iomanip>


using namespace std;


int main()
{


cout<< "Enter the year you wish to inquire about";
int x;//The year for which it is desired to compute Easter Sunday.
cin>> x;//The 4-digit year.
if (x<0001 || x>9999)
cout<<"The year has to be between 0001 & 9999"<<endl;
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 sunday = (22 + d + e);//The calculation of easter sunday.
int month = (sunday/31);
cout<<setw(4)<< "Day" <<setw(8)<< "Month" <<setw(8)<< "Year"<<endl;
cout<<setw(4)<<sunday<<setw(6)<<month<<setw(10)<<x<<endl;

I'm still playing around with it...Thx.

zandiago 115 Nearly a Posting Maven Featured Poster

Even though for 'x', i inputted a value between 0001 and 9999-why does it still show the 'cout' statement that I have there?

zandiago 115 Nearly a Posting Maven Featured Poster
#include "stdafx.h"
#include <iostream>
#include <string>
#include <cmath>
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
#include <iomanip>


using namespace std;


int main()
{
cout<< "Enter the year you wish to inquire about";
int x;//The year for which it is desired to compute Easter Sunday.
cin>> x;//The 4-digit year.
if (x<0001 || x>9999);
cout<<"The year must be between 0001 and 9999"<<endl;
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<<setw(4)<< "Day" <<setw(8)<< "Month" <<setw(8)<< "Year"<<endl;
cout<<setw(20)<<x<<endl;


return 0;

Well i'm going to see if I can read up on arrays-we are in out first month of class, so i don't know what arrays are....this project is due on monday, so i'm going to need all the assistance that i can get. Thx.

zandiago 115 Nearly a Posting Maven Featured Poster
#include "stdafx.h"
#include <iostream>
#include <string>
#include <cmath>
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
#include <iomanip>


using namespace std;


int main()
{
cout<< "Enter the year you wish to inquire about";


int x;//The year for which it is desired to compute Easter Sunday.
cin>> x;//The 4-digit year.
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<<setw(4)<< "Day" <<setw(8)<< "Month" <<setw(8)<< "Year"<<endl;
cout<<setw(20)x<<endl;


return 0;
}

But doesn't my position of 'cin' allow for that value to be calculated? I was able to get the year...and how does this program require a 'if' and 'else' statements?

zandiago 115 Nearly a Posting Maven Featured Poster

Also, where do the 'if' and 'else' statements come into play with such a program?

zandiago 115 Nearly a Posting Maven Featured Poster

You want to run that by me again? If i enter a value from the keyboard-doesn't a program automatically do the calculation? You kinna lost me there.

zandiago 115 Nearly a Posting Maven Featured Poster

Ok...thx for your help-now I see it. But where would and 'if' else statement be necessary in such a program? I'm in my first month of C++ and I'm struggling to catch on to it. I really appreaciate all the assistance. I had tried and example- i had inputted '1999'- and i got a result of '749'. I know it doesn't make any sense, but It's suppose to calculate and show the day, month and year. Thx.

zandiago 115 Nearly a Posting Maven Featured Poster

Ok...thx for your help-now I see it. But where would and 'if' else statement be necessary in such a program? I'm in my first month of C++ and I'm struggling to catch on to it. I really appreaciate all the assistance. I had tried and example- i had inputted '1999'- and i got a result of '749'. I know it doesn't make any sense, but It's suppose to calculate and show the day, month and year. Thx.

zandiago 115 Nearly a Posting Maven Featured Poster

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 …