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 4 of 4

Thread: Getting error message and can not figure it out.

  1. #1
    Junior Member
    Join Date
    Jul 2013
    Posts
    4
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default Getting error message and can not figure it out.

    I have been working on this assignment for 2 days now and I have had this error message. I hope a fresh set of eyes will help me.
    Here is my code
    import javax.swing.JOptionPane;
     
    //Louis Friedmann
    //July 09, 2013
    //This program prints the output in dialog boxes
     
     
     
     
    public class DateJDialog
    {
     
    	 public static void main(String[] args) {
     
     
    	         //Variables Declaration
    	         String inputString; //input
    	         int dayIs;  //day
    	         int yearIs; // year
    	         int monthIs; //month
    	         String leapResult; // tell's whether it's a leap year or not.
     
    	         //Input
    	         inputString = JOptionPane.showInputDialog("What is the day?");
    	         dayIs = Integer.parseInt(inputString);
     
    	         inputString = JOptionPane.showInputDialog("What is the month?");
    	         monthIs = Integer.parseInt(inputString);
     
    	         inputString = JOptionPane.showInputDialog("What is the year.");
    	         yearIs = Integer.parseInt(inputString);
     
    	         //calculation
    	         if (isLeapYear(yearIs))
    	         {
    	             leapResult = " is a leap year";
    	         } else
    	         	{
    	             leapResult = yearIs + " isn't a leap year";
    	         	}
     
    	         //output
    	         JOptionPane.showMessageDialog(null, leapResult);
     
    	         //exits the program
    	         System.exit(0);
        }
     
     
    }

    And this is my error message:

    C:\Users\Friedmann\Desktop\Java\Assignment 5\DateJDialog.java:34: error: cannot find symbol
    if (isLeapYear(yearIs))
    ^
    symbol: method isLeapYear(int)
    location: class DateJDialog
    1 error

    Tool completed with exit code 1

    Please help!!!!!!

    Thanks.


  2. #2
    Junior Member
    Join Date
    Jul 2013
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Getting error message and can not figure it out.

    I can't find the isLeapYear(int) method in your code. Since each method must be defined in the class or statically imported before being called, and you calls the undefined method in your code, the compiler of course will throw an error. To solve this problem, you need to add the definition of the static method isLeapYear(int) to the class body. As to how to decide wether it is a leap year or not, I think it's not hard for you to figure out.

  3. #3
    Junior Member
    Join Date
    Jul 2013
    Posts
    14
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: Getting error message and can not figure it out.

    u re missing isLeapYear() method

  4. #4
    Senior Member PhHein's Avatar
    Join Date
    Mar 2013
    Location
    Germany
    Posts
    609
    My Mood
    Sleepy
    Thanks
    10
    Thanked 93 Times in 86 Posts

    Default Re: Getting error message and can not figure it out.

    you and are! This is a forum, not an SMS system you can use more than 160 chars.

Similar Threads

  1. Need help with error message!!
    By Rick Sebastian in forum What's Wrong With My Code?
    Replies: 14
    Last Post: March 25th, 2013, 10:24 AM
  2. Can't figure out my error
    By bigtrouble187 in forum What's Wrong With My Code?
    Replies: 3
    Last Post: May 29th, 2012, 01:15 PM
  3. I can't figure out why i keep getting this error
    By chrissy2860 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: September 17th, 2011, 03:06 PM
  4. just one more error that i cannot figure out please help me.
    By knoxy5467 in forum What's Wrong With My Code?
    Replies: 31
    Last Post: June 14th, 2011, 09:04 AM
  5. help with a error message
    By JavaNoob82 in forum What's Wrong With My Code?
    Replies: 6
    Last Post: January 23rd, 2010, 02:56 PM