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


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Zellar's Congruence error

  1. #1
    Junior Member
    Join Date
    Sep 2012
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default 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;
     
        	int answer = (int)dayOfWeek;
     
        	System.out.println("Day of the week is " + DAY_OF_WEEK[answer]);
     
        }
    }


  2. #2
    Junior Member
    Join Date
    Sep 2012
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

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

Similar Threads

  1. Please! Help me to this error "ERROR CANNOT FIND SYMBOL"
    By mharck in forum Object Oriented Programming
    Replies: 8
    Last Post: July 3rd, 2012, 09:20 AM

Tags for this Thread