GavinVG
New Member
- Joined
- Apr 14, 2010
- Messages
- 13 (0.00/day)
So i have to write a program that does this: Given the year inputted by the user, calculate the month and day of Easter Sunday. When the
program executes, it should produce output similar to this.
Easter Sunday Calculator
Enter the year: 1985
Easter Sunday is April 7, 1985
The formula is a complex one and produces the correct day for any year from 1900
through 2099. I have broken it down into intermediate steps as follows. Frequently, Easter
Sunday is in March, but occasionally it is in April. The following formula calculates the day of
the month in March of Easter Sunday.
let a = year % 19
let b = year % 4
let c = year % 7
now start to put these pieces together
let d = (19 * a + 24) % 30
let e = (2 * b + 4 * c + 6 * d + 5) % 7
finally, the day of the month of Easter Sunday is
let day = 22 + d + e
However, if the day is greater than 31, then subtract 31 days from day and the resulting value in day is in April instead. But the equation is off by exactly 7 days if these years are used: 1954, 1981, 2049 and 2076. Thus, when the calculation is finished, if the year is one of these four, you must subtract 7 days from the day variable. The subtraction does not cause a change in the month.
Well i dont know how to get past my Input stage. I basically dont know how to start it after that i will probably be able to finish other stages. I just need help on how the Process stage should start
program executes, it should produce output similar to this.
Easter Sunday Calculator
Enter the year: 1985
Easter Sunday is April 7, 1985
The formula is a complex one and produces the correct day for any year from 1900
through 2099. I have broken it down into intermediate steps as follows. Frequently, Easter
Sunday is in March, but occasionally it is in April. The following formula calculates the day of
the month in March of Easter Sunday.
let a = year % 19
let b = year % 4
let c = year % 7
now start to put these pieces together
let d = (19 * a + 24) % 30
let e = (2 * b + 4 * c + 6 * d + 5) % 7
finally, the day of the month of Easter Sunday is
let day = 22 + d + e
However, if the day is greater than 31, then subtract 31 days from day and the resulting value in day is in April instead. But the equation is off by exactly 7 days if these years are used: 1954, 1981, 2049 and 2076. Thus, when the calculation is finished, if the year is one of these four, you must subtract 7 days from the day variable. The subtraction does not cause a change in the month.
Well i dont know how to get past my Input stage. I basically dont know how to start it after that i will probably be able to finish other stages. I just need help on how the Process stage should start