I am trying to calculate the date of easter in the years 1900-2099 ,inclusive.And a,b,c,d,e variables are defined as in program and the date of easter is March 22+d+e(which may be in april),except in the years 1954,1981,2049 and 2076 when easter is one week earlier than the formula given.
From programming point of view,I am new and i tried the program as below but it is not in order and there are so many errors..how do i fix it..any help would be very helpful..

Now i have to request a starting and ending years from the user and validate input to make sure that lies in the range of years.I am new and i tried the program as below but it is not in order and there are so many errors..how do i fix it..any help would be very helpful..

#include<iostream>
#include<iomanip>
using namespace std;
void DisplayIntro();
enum Months {JAN,FEB,MAR ,APR ,MAY ,JUN ,
           JUL ,AUG ,SEP ,OCT, NOV ,DEC }
void GetYears(int&Yr1,int&Yr2);
void EasterDay(int,int, Months&,int&);
bool MoreYears();
void main()
{
    int Year1,Year2;
    Months Month;
    int Day;
    DisplayIntro();
    do{
    GetYears(Year1,Year2);
    for( Year1=1900;Year1<=2099;Year1++)
    {
        EasterDay(Year1,Year2,Month,Day);
        
        if(Month==MAR)
            cout<<"March";
        else 
            cout<<"April";
        cout<<setw(3)<< Day","<<setw(5)<<Year<<endl;
            }

    while(MoreYears());
    cout << "\n Easter Day processing has ended.\n\n";
    }
void displayIntro()
{
    cout<<"EASTER DAY CALCULATION\n"
          "\n Enter two starting and ending years "
          "And the Easter days will be Displayed"
          "The Starting year must not be after the ending year and both years 
          "\nmust be integers in the range 1900-2099.\n";
}



void GetYears(int&yr1,int&yr2)
{
    cout<<"Enter the  Starting and Ending years(Between 1900-2099 inclusive):";
    cin>>yr1>>yr2;
}

void EasterDate (int Year1, Year2,MonthType & Month, int &  Day )
{
    int a,
        b,
        c,
        d,
        e,
        calc
        Year;
    a=Year%19;
    b=Year%4;
    c=Year%7;
    d=(19a+24)%30;
    e=(2b+4c+6d+5)%7;
    calc = 22+d+e;
    if( calc> 31)
            {
                Month = April;
                Day = calc - 31;
            }
            else
            {
                Month = March;
                Day = calc;
            }
        }

  if (int Year==1954||Year==1954||Year==1981||Year==1981||Year==2049||Year==2049||Year==2076||Year==2076)
  {
      Day = calc - 7;
}
  
            

bool MoreYears()
{
    char response;
    for (;;)
    {
        cout << "\nProcess more yeras? Enter Y for Yes or N for No: ";
        cin >> response;
        cin.ignore(256, '\n');
        response = toupper(response);
        if (response == 'Y' || response == 'N')
            break;
        cout << "Invalid response! Try again.\n";
    }
    return (response == 'Y');
}

Recommended Answers

All 7 Replies

The error messages are supposed to tell you what the errors are. Learn to read and correct them yourself.
When you are writing programs, do not write the whole program at once, and then try your luck with the compilation. The correct way is to write and compile, function by function, or better block by block, and if possible line by line.

If you use a good code editor with syntax highlighting, rather than something like notepad, or at least if you had some kind of consideration to use code tags when dumping the code here, you would have seen that the syntax highlighting is messed up from line 38 and downwards. This maybe the result of some kind of delimiter that is missing in the code. Looking closely just above line 38, because that is where the incorrect syntax highlighting begins to show, we see that a double quotation mark " is missing at the end of line 37. Try adding it and compiling again. Maybe that is the only error. If you comeup with other errors, do post them when you reply again. And use code tags.

http://cboard.cprogramming.com/showthread.php?t=88495
The first step would be to not try and write the program all in one sitting.

That just results in a huge mess, and we're not here for you to write a large amount of code then dump it on a message board for someone else to fix.

I would suggest stages of
- print the intro banner
- prompt for years and print the range
- perform the calculation for a known year
- perform the calculation for the range of years
- add the yes/no again loop

Okay but i am still trying to know the flow of program .So i am unable to execute/write 1 by1 block basis.there are all codes but they are not in order ..thank you for ur help..

this is my third program,and errors are similar but i coulnot fix them and i need this program to work first sothat i may look it as a reference.So ur help is highly helpful to me(just for this program,according as need)..

Does anybody know how to rearrange this code sothat it gives desire output.

> this is my third program,and errors are similar but i coulnot fix them
Like I said, the error is in your approach, namely trying to write too much code without pressing "compile" or running the results to make sure you're still on track.

Sooner or later, you'll have to learn how to do this, because nobody sits down and writes say "firefox" just by bashing the keyboard for several days, pressing compile and hey presto, instant working browser.

Think small, take baby steps, start with

int main ( ) {
  return 0;
}

Which becomes

void DisplayIntro();

int main ( ) {
  DisplayIntro();
  return 0;
}

void displayIntro()
{
    cout<<"EASTER DAY CALCULATION\n"
          "\n Enter two starting and ending years "
          "And the Easter days will be Displayed"
          "The Starting year must not be after the ending year and both years 
          "\nmust be integers in the range 1900-2099.\n";
}

Now, if you try to compile this second one, you'll see at least one problem. Try to fix it before moving on with the next step.

The next step is to add ONE MORE FUNCTION AT A TIME until you've built up the complete program. After making each function compile, run the code to make sure it does what you want.

Yes, anyone here could copy/paste the fixed solution, but that just isn't going to teach you anything at all about how to fix your own code, and you'll be back in a few more days with your next program but the same issues.

commented: Great advice for a beginner +7
commented: Really a thing that must be practiced and never ignored by novices. +3

Okay finally i got the desired output.Thanks all of u guys.It took me time but got what i needed.hoping further help..

commented: Congratulations! +9
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.