Lab 1: Easter Sunday
Web-CAT: Submit Java programs to this automated grading platform.
Background
- Due Date: Thursday, September 12, 2019
- Total Points: 10
- In this lab, you must write a
Javaprogram that determines which particular day and month that Easter Sunday appears.
Code Distribution
| Description | File Size | File Name |
|---|---|---|
Java Source Code for Easter Sunday |
4.8KB | lab01.zip |
Contents of lab01.zip:
Lab01EasterSunday/
├── EasterSunday.class
├── EasterSunday.ctxt
├── EasterSunday.java
├── EasterSundayJUnitTest.class
├── EasterSundayJUnitTest.ctxt
├── EasterSundayJUnitTest.java
├── package.bluej
└── README.TXT
Specification
- Write a
Javaprogram in the fileEasterSunday.javathat computes the date of Easter Sunday, given a particular year. Easter Sunday is a holiday which falls on the first Sunday after the first full moon of Spring. This algorithm was discovered by Carl Friedrich Gauss. - The parameter
yearis the variable for the year in question. In the provided code,yeartakes on the value2001. - Your program must perform the following calculations:
- Divide
yearby19and call the remaindera. Ignore the quotient. - Divide
yearby100to get a quotientband a remainderc. - Divide
bby4to get a quotientdand a remaindere. - Divide
(8 * b + 13)by25to get a quotientg. Ignore the remainder. - Divide
(19 * a + b - d - g + 15)by30to get a remainderh. Ignore the quotient. - Divide
cby4to get a quotientjand a remainderk. - Divide
(a + 11 * h)by319to get a quotientm. Ignore the remainder. - Divide
(2 * e + 2 * j - k - h + m + 32)by7to get a remainderr. Ignore the quotient. - Divide
(h - m + r + 90)by25to get a quotientn. Ignore the remainder. - Divide
(h - m + r + n + 19)by32to get a remainderp. Ignore the quotient. - The result is that Easter Sunday falls on day:
pof the month:n.
- Divide
- For example, given the year
2001, we find that the result is:n = 4andp = 15. This means that Easter Sunday was on April 15 in the year 2001. - You will write your solution in a function called
retrieveDate(int year), right below the place where it says:YOUR CODE HERE.
Testing
- Click on the Run Tests button to execute the
JUnittest bench.JUnitindicates a successful test with a green bar, and an unsuccessful test with a red bar.
Submission
- Upload the file
EasterSunday.javato the Web-CAT automated grading platform.