Zellar's Congruence error
Hello everyone, so I'm brand new to java (3 weeks of instruction) I think I'm close on this formula(Zellar's Congruence), but I'm getting "error: cannot find symbol" on line 33 when I attempt to compile, I've re-written the formula a couple times and am continuing to get this error. Any help or insight would be much appreciated. Thanks
Code java:
import java.util.Scanner;
public class Project1_3_7 {
public static void main(String[] args) {
Scanner scanner = new Scanner (System.in);
final String[] DAY_OF_WEEK = {"Saturday", "Sunday", "Monday",
"Tuesday", "Wednesday", "Thursday", "Friday"};
System.out.print("Enter year: (e.g, 2012): ");
int year = scanner.nextInt();
System.out.print("Enter Month: 1-12: ");
int month = scanner.nextInt();
System.out.print("Enter the day of the month: 1-31: ");
int dayOfMonth = scanner.nextInt();
if (month == 1)
month = 13;
else if (month == 2)
month = 14;
int century = year / 100;
int yearOfCentury = year % 100;
int dayOfWeek = (day + ((26*(month + 1)) / 10) +
yearOfCentury + (yearOfCentury / 4) + (century / 4) +
(5 * century)) % 7;
int answer = (int)dayOfWeek;
System.out.println("Day of the week is " + DAY_OF_WEEK[answer]);
}
}
Re: Zellar's Congruence error
I figured it out, just a stupid mistake that I think stemmed from me working on this too long...
Code java:
int dayOfWeek =(dayOfMonth +((26*(month + 1)) / 10) +
yearOfCentury + (yearOfCentury / 4) + (century / 4) +
(5 * century)) % 7;
I managed to mix up what variable i used for the "dayOfMonth"...