CISH-4020 Object Structures
Assignment 1
Write a program to compute the date of Easter Sunday. Easter Sunday is the first Sunday after the first full moon of Spring. Use the following algorithm, invented by the mathematician Carl Friedrich Gauss in 1800 (note: this algorithm is only valid for dates after 326AD in the Julian calendar):
- Let
y
be the year (such as 1800, or 2001)- Divide
y
by 19 and call the remaindera
. Ignore the quotient.- Divide
y
by 100 to get the quotientb
and remainderc
- Divide
b
by 4 to get a quotientd
and remaindere
- Divide
8 * b + 13
by 25 to get the quotientg
. Ignore the remainder.- Divide
19 * a + b - d - g + 15
by 30 to get a remainderh
. Ignore the quotient.- Divide
c
by 4 to get the quotientj
and remainderk
- Divide
a + 11 * h
by 319 to get the quotientm
. Ignore the remainder.- Divide
2 * e + 2 * j - k - h + m + 32
by 7 to get a remainderr
. Ignore the quotient.- Divide
h - m + r + 90
by 25 to get the quotientn
. Ignore the remainder.- Divide
h - m + r + n + 19
by 32 to get a remainderp
. Ignore the quotient.
After all that, you will find that Easter falls on day p
of month n
. For example, if y
is 2001:
a = 6
b = 20
c = 1
d = 5, e = 0
g = 6
h = 18
j = 0, k = 1
m = 0
r = 6
n = 4
p = 15
Therefore, in 2001, Easter Sunday fell on April 15.
Write a class EasterSunday
with methods getEasterSundayMonth
, getEasterSundayDay
, and getEasterSundayYear
. The constructor for EasterSunday
will take a single integer parameter representing the year in question. getEasterSundayDay
and getEasterSundayYear
will return integer values, while getEasterSundayMonth
will return the name of the month. Be sure to follow the class coding guidelines - however, for this assignment you can ignore the rules governing variable naming as well as the admonitions against magic numbers for the code representing Gauss' equations
You'll also need a driver class to test your EasterSunday
class. The app class will ask the user for year to compute the date of Easter Sunday. It will then report the date of Easter Sunday for the given year. Your driver class should loop until the user enters 0 for the year.
Since we won't be covering exceptions and I/O until next class, you'll need help getting input from the keyboard. You can use the CS1 jar file which contains the Keyboard class for your input needs. Refer to the Eclipse documentation to include the jar in your project.
Your output should look like the following (user input in green):
|
Submit your .java
files to blought@rh.edu no later than 5:00pm on 5/18/04. Your code will be graded on correctness, output, reusability, readability, and documentation.