I have a problem to determine Easter Sunday based on the algorithm invented by Carl Friedrick Gauss in 1800. I have written my code and double checked the Math several times but not matter what year I type in it tells me that Easter is on April 9th so I must have something wrong in the code. Any help would be great.
import java.util.Scanner;
public class EasterSunday
{
public EasterSunday(int y)
{
}
public int recordYear(int y)
{
return y;
}
public double getEasterSundayMonth()
{
a = y % 19;
b = y / 100;
c = y % 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;
return n;
}
public double getEasterSundayDay()
{
p = (h - m + r + n + 19) % 32;
return p;
}
private static int y;
private int a;
private int b;
private int c;
private int d;
private int e;
private int g;
private int h;
private int j;
private int k;
private int m;
private int r;
private double n;
private double p;
public static void main(String[] args)
{
Scanner in = new Scanner(System.in);
EasterSunday easter = new EasterSunday(y);
System.out.print("Enter the year: ");
int y = in.nextInt();
easter.recordYear(y);
System.out.println(easter.getEasterSundayMonth());
System.out.println(easter.getEasterSundayDay());
}
}