Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Therefore, in 2001, Easter Sunday fell on April 15. Write a java program that pr

ID: 3792980 • Letter: T

Question

Therefore, in 2001, Easter Sunday fell on April 15. Write a java program that prompts the user for a year and prints out the month and day of Easter Sunday. your assis P4.2 Easter Sunday is the first Sunday after the first full moon of spring. To compute the date, you can use this algorithm, invented by the mathematician Carl Friedrich Gauss in 1800: 1. Let y be the year (such as 1800 or 2001). 2. Divide y by 19 and call the remainder a. Ignore the quotient. 3. Divide y by 100 to get a quotient b and a remainder c. 4. Divide b by 4 to get a quotient d and a remainder e. 5. Divide 8 b 13 by 25 to get a quotient g. Ignore the remainder. 6. Divide 19 a b d g 15 by 30 to get a remainder h. Ignore the quotient 7. Divide c by 4 to get a quotient j and a remainder k. 8. Divide a 11 h by 319 to get a quotient m. Ignore the remainder. 9. Divide 2 e 2 j k h m 32 by 7 to get a remainder r. Ignore the quotient. 10. Divide h m r 90 by 25 to get a quotient n. Ignore the remainder. 11. Divide h m r n 19 by 32 to get a remainder p. Ignore the quotient. Then Easter falls on day p of month n. For example, if y is 2001: b 20, c 1 18 15 d 5, e

Explanation / Answer


import java.util.Scanner;

class Easter
{
public static void main(String[] args)
{
System.out.print("Enter year to calculate Easter Sunday >");
Scanner s = new Scanner(System.in);
int in_yr = s.nextInt();
if(in_yr <= 0)
System.out.print("Expected a positive year. Please try again: ");  
           else
System.out.println("Therefore, in "+in_yr+ ", Easter Sunday fell on "+getEasterSundayDate(in_yr));
}
public static String getEasterSundayDate(int year)
{
int a = year % 19,
b = year / 100,
c = year % 100,
d = b / 4,
e = b % 4,
g = (8 * b + 13) / 25,
h = (19 * a + b - d - g + 15) % 30,
j = c / 4,
k = c % 4,
m = (a + 11 * h) / 319,
r = (2 * e + 2 * j - k - h + m + 32) % 7,
n = (h - m + r + 90) / 25,
p = (h - m + r + n + 19) % 32;

String result;
switch(n)
{
case 1:
result = "January ";
break;
case 2:
result = "February ";
break;
case 3:
result = "March ";
break;
case 4:
result = "April ";
break;
case 5:
result = "May ";
break;
case 6:
result = "June ";
break;
case 7:
result = "July ";
break;
case 8:
result = "August ";
break;
case 9:
result = "September ";
break;
case 10:
result = "October ";
break;
case 11:
result = "November ";
break;
case 12:
result = "December ";
break;
default:
result = "error";
}

return result + p;
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote