A convenient algorithm for determining the date of Easter in a given year was devised in 1876 and first appeared in Butcher’s Ecclesiastical Handbook. This algorithm holds for any year in the Gregorian calendar, which means years including and after 1583. Subject to minor adaptations, the algorithm is as follows:
The value of n
gives the month (3 for March and 4 for April) and the value of p + 1
gives the day of the month. For example, if y
is 2003:
a = 8
b = 20
c = 3
d = 5
e = 0
f = 1
g = 6
h = 26
i = 0
k = 3
r = 3
m = 0
n = 4
p = 19
Therefore, in 2003, Easter fell on April 20 (month = n = 4 and day = p + 1 = 20).
Basic Assignment:
Write a program that calculates the day that Easter falls on for a given year.
The program should display the values for all of the variables and the date for Easter. A Sample run output for the year 2003 would be:
a = 3 b = 20 c = 17 d = 5 e = 0 f = 1 g = 6 h = 21 i = 4 k = 1 r = 4 m = 0 n = 4 p = 15
Easter in 2017 falls on 4/16
Verify that your program gives all the output shown above for the year 2017.
Verify that your program gives the correct date for these years:
Easter in 2000 falls on 4/23
Easter in 2001 falls on 4/15
Easter in 2002 falls on 3/31
Challenge Assignments:
A Sample run output for the year 2003 would be:
a = 8 b = 20 c = 3 d = 5 e = 0 f = 1 g = 6 h = 26 i = 0 k = 3 r = 3 m = 0 n = 4 p = 19
Easter in 2003 falls on 4/20 Independence Day in 2003 falls on a Friday
If everything above was too easy for you, try coding the Easter lab in a language you've never used before. How about Python, C++, Javascript, PHP, Perl, or Ruby? Or perhaps something really obscure like Brain**k? Pick a language from the IDE list online at Tutorials Point
If you write your code in a language in addition to Java, upload your additional file by dragging multiple files onto the submission form's Upload button. And be sure to name your file using our standard convention. For example, P3_Wang_Michael_Easter.cpp
would be for a C++ file.
Instructions:
public class PX_LastName_FirstName_Easter
{
public static void main(String[] args) {
// Year to calculate Easter
int y = 2017;
// Perform Easter calculations
int a = y % 19;
System.out.println("a = " + a);
int b = y / 100;
System.out.println("b = " + b);
...
// Print out final result
...
Important!! From now on you must name your files and classes following this naming convention:
P#_LastName_FirstName_Assignment.java
Example: P2_Wang_Michael_Easter.java
.
After completing the program, upload it by 11:59 pm on the due date using the form below.
You must Sign In to submit to this assignment
Last modified: December 12, 2022
Back to Summary