Welcome to the Java Programming Forums

The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.

>> REGISTER NOW TO START POSTING

1. ## 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

```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;

System.out.println("Day of the week is " + DAY_OF_WEEK[answer]);

}
}```

2. ## Re: Zellar's Congruence error

I figured it out, just a stupid mistake that I think stemmed from me working on this too long...

```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"...