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

import java.util.Scanner; // Enables user input. public class Easter { public st

ID: 3846068 • Letter: I

Question

import java.util.Scanner; // Enables user input.

public class Easter {
  
  
public static void main(String[] args) {
Scanner scnr = new Scanner(System.in);
int year = 0;
  
// FIXME: Declare variables
  
  
System.out.println("Please enter a year: ");
// FIXME: Obtain user input


// FIXME: Calculations
  
  
/* If n equals 3, Easter month falls in March
If n equals 4, Easter month falls in April
Otherwise, there is a mistake.
*/
if (monthEaster == 3) {
System.out.print("In year " + year + ", Easter falls on March " + dayEaster + ".");
}
else if (monthEaster == 4) {
System.out.print("In year " + year + ", Easter falls on April " + dayEaster + ".");
}
  
else {
System.out.println("This is a mistake! Please enter a 4-digit year.");
}
  
return;
}

Prompt the user to enter a 4-digit year. Declare the variable and complete the expressions to find the Easter date in a given year. The program will display the Easter month and day for the year.

a is the year modulus 19

b is the year divided by 100

c is the year modulus 100

d is b divided by 4

e is b modulus 4

g is (8*b + 13) divided by 25

h is (19*a + b - d - g + 15) modulus 30

j is c divided by 4

k is c modulus 4

L is (a + 11*h) divided by 319

m is (2e + 2j - k - h + L + 32) modulus 7

monthEaster is (h - L + m + 90) divided by 25

dayEaster is (h - L + m + monthEaster + 19) modulus 32

Explanation / Answer

Please find the completed code along with the comments.

import java.util.Scanner;

class Easter {

public static void main(String[] args) {
Scanner scnr = new Scanner(System.in);
int year = 0;
  
int a,b,c,d,e,g,h,j,k,L,m,monthEaster,dayEaster;   //variable declaration
  
  
System.out.println("Please enter a year: ");
year = scnr.nextInt();   //read the year from user
  
a = year % 19;   // do the calculations as per the question
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;
L = (a + 11*h) / 319;
m = (2*e + 2*j - k - h + L + 32) % 7;
monthEaster = (h - L + m + 90) / 25;
dayEaster = (h - L + m + monthEaster + 19) % 32;
  
  
/* If n equals 3, Easter month falls in March
If n equals 4, Easter month falls in April
Otherwise, there is a mistake.
*/
if (monthEaster == 3) {
System.out.print("In year " + year + ", Easter falls on March " + dayEaster + ".");
}
else if (monthEaster == 4) {
System.out.print("In year " + year + ", Easter falls on April " + dayEaster + ".");
}
  
else {
System.out.println("This is a mistake! Please enter a 4-digit year.");
}
  
return;
}
}

-----------------------------------------------------------------------

OUTPUT:

Please enter a year:
2017
In year 2017, Easter falls on April 16.