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

Thread: Cannot find Symbol?

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

    Default Cannot find Symbol?

    I was given a problem:

    Design a TestScores class that has fields to hold three test scores. The class should have accessor and mutator methods for the test score fields, and a method that returns the average of the test scores. Demonstrate the class by writing a separate program that creates an instance of the class. The program should ask the user to enter three test scores, which are stored in the TestScores object. Then the program should display the average of the scores, as reported by the TestScores object.

    The class seems to work fine, its the exe file that isnt running. I get

    G:\CIS 18A\week2\Test_KagawaDavidDemo.java:12: cannot find symbol
    symbol : constructor Test_KagawaDavid()
    location: class Test_KagawaDavid
    Test_KagawaDavid Scores = new Test_KagawaDavid();
    ^
    G:\CIS 18A\week2\Test_KagawaDavidDemo.java:16: cannot find symbol
    symbol : variable nextDouble
    location: class java.util.Scanner
    Scores.setTest1(input.nextDouble);
    ^
    G:\CIS 18A\week2\Test_KagawaDavidDemo.java:19: cannot find symbol
    symbol : variable nextDouble
    location: class java.util.Scanner
    Scores.setTest2(input.nextDouble);
    ^
    G:\CIS 18A\week2\Test_KagawaDavidDemo.java:22: cannot find symbol
    symbol : variable nextDouble
    location: class java.util.Scanner
    Scores.setTest3(input.nextDouble);
    ^
    4 errors


    /* This is the Class */

     args)
    	{
    		Test_KagawaDavid Scores = new Test_KagawaDavid();
    		Scanner input = new Scanner(System.in);
     
    		System.out.println("Enter Test1 ");
    		Scores.setTest1(input.nextDouble);
     
    		System.out.println("Enter Test2 ");
    		Scores.setTest2(input.nextDouble);
     
    		System.out.println("Enter Test3 ");
    		Scores.setTest3(input.nextDouble);
     
    		System.out.println("Average of these scores is: " + Scores.average());
     
    		JOptionPane.showMessageDialog(null,"Program Complete");
     
                   }
    }

    What Am I doing Wrong?


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Cannot find Symbol?

    Where are the definitions for the symbols that the compiler can't find? (symbol is compiler talk for word or token)

    Check the API doc for the Scanner class. Are you trying to use a method of that class or get to one of its variables? Hint: method calls end with ()s.

  3. #3
    Forum old-timer
    Join Date
    Nov 2008
    Location
    Faversham, Kent, UK
    Posts
    472
    My Mood
    Mellow
    Thanks
    4
    Thanked 58 Times in 54 Posts

    Default Re: Cannot find Symbol?

    The compiler says it can't find the constructor for the Test_KagawaDavid class. Is that class in the same package or are you importing it? Can you post the code for it?

  4. #4
    Grand Poobah
    Join Date
    Mar 2011
    Posts
    1,545
    My Mood
    Grumpy
    Thanks
    0
    Thanked 167 Times in 158 Posts

    Default Re: Cannot find Symbol?

    For the other errors is says cannot find variable nextDouble. Perhaps it is a method instead.

    Error messages are there for a reason. If you plan on learning programming then you need to read them and attempt to fix them yourself. Most are fairly basic and easy to identify what you have done wrong.

    Ooops! I didn't see Norm's reply. Must get my eyes checked.

  5. #5
    Forum old-timer
    Join Date
    Nov 2008
    Location
    Faversham, Kent, UK
    Posts
    472
    My Mood
    Mellow
    Thanks
    4
    Thanked 58 Times in 54 Posts

    Default Re: Cannot find Symbol?

    Quote Originally Posted by Junky View Post
    Ooops! I didn't see Norm's reply. Must get my eyes checked.
    Should have gone to BugSavers

  6. #6
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Cannot find Symbol?

    BugSavers
    Is that a UK thing?

  7. #7
    Forum old-timer
    Join Date
    Nov 2008
    Location
    Faversham, Kent, UK
    Posts
    472
    My Mood
    Mellow
    Thanks
    4
    Thanked 58 Times in 54 Posts

    Default Re: Cannot find Symbol?

    Quote Originally Posted by Norm View Post
    Is that a UK thing?
    Yes, it would seem so. Pardon my cultural parochialism - there's a ubiquitous advertising campaign in the UK for cheap spectacles by a company called SpecSavers, which shows silly mistakes caused by poor eyesight (e.g. sheep shearer shearing his sheep-dog), with the tag-line "Should have gone to SpecSavers".

    Seemed amusing at the time...

  8. #8
    mmm.. coffee JavaPF's Avatar
    Join Date
    May 2008
    Location
    United Kingdom
    Posts
    3,336
    My Mood
    Mellow
    Thanks
    258
    Thanked 294 Times in 227 Posts
    Blog Entries
    4

    Default Re: Cannot find Symbol?

    Quote Originally Posted by dlorde View Post
    Yes, it would seem so. Pardon my cultural parochialism - there's a ubiquitous advertising campaign in the UK for cheap spectacles by a company called SpecSavers, which shows silly mistakes caused by poor eyesight (e.g. sheep shearer shearing his sheep-dog), with the tag-line "Should have gone to SpecSavers".

    Seemed amusing at the time...
    I laughed out loud
    Please use [highlight=Java] code [/highlight] tags when posting your code.
    Forum Tip: Add to peoples reputation by clicking the button on their useful posts.

  9. #9
    Forum old-timer
    Join Date
    Nov 2008
    Location
    Faversham, Kent, UK
    Posts
    472
    My Mood
    Mellow
    Thanks
    4
    Thanked 58 Times in 54 Posts

    Default Re: Cannot find Symbol?

    Quote Originally Posted by JavaPF View Post
    I laughed out loud
    My life has not been wasted (yet)

Similar Threads

  1. Cannot find symbol error
    By AnuR in forum What's Wrong With My Code?
    Replies: 9
    Last Post: February 23rd, 2011, 02:50 PM
  2. Cannot find symbol?
    By stealthmonkey in forum What's Wrong With My Code?
    Replies: 3
    Last Post: December 10th, 2010, 10:02 PM
  3. cannot find symbol Error
    By bananasplitkids in forum What's Wrong With My Code?
    Replies: 2
    Last Post: March 9th, 2010, 02:36 AM
  4. Why the compiler can not find the symbol?
    By AlicNewbie in forum What's Wrong With My Code?
    Replies: 1
    Last Post: February 16th, 2010, 08:16 PM
  5. cannot find symbol - method
    By kyuss in forum Object Oriented Programming
    Replies: 2
    Last Post: December 7th, 2009, 01:01 PM