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

Thread: cannot find symbol in reference variable

  1. #1
    Junior Member
    Join Date
    Nov 2010
    Posts
    3
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default cannot find symbol in reference variable

    I am writing a program for my class that asks the user for a specific type of internet package and how many hours they will spend on the internet.


    I only have package A on this right now, but I will add the other packages after this error is fixed.

    The error message I have is as follows:

    IspTester.java:36: cannot find symbol
    symbol : constructor InternetAccount()
    location : class InternetAccount
    InternetAccount pack = new InternetAccount();

    thank you very much for your future help!


    This is the program that has the error.

       import java.util.Scanner;
     
       public class IspTester
       {
          public static void main(String[] args)
          {
     
          //Naming variables
             double hours;
             String packageType;
     
          //Create a Scanner object to read from the keyboard
             Scanner keyboard = new Scanner(System.in);
     
          //Ask for hours used and package type
             System.out.print("Enter the hours used and the package type: ");
             hours = keyboard.nextDouble();
             packageType = keyboard.nextLine().trim();
     
          //Declare and instantiiate an object reference variable
             InternetAccount pack = new InternetAccount();
     
          //Set the package type based on the user input
             if (packageType.equalsIgnoreCase("A"))
             {
                pack.setCostOfA(hours);
             }
             else
             {
                pack.setCostOfA(hours);
             }
          }
       }


    and this is the other program that has the setter and getter methods and such.

       public class InternetAccount
       {
       //Naming variables
          private double monthlyHours,
          				subType,
          				subAHours,
          				subBHours,
          				subCHours;
          private double	subA,
          				subB,
          				subC;
     
     
       //Constructor
          public InternetAccount(double m, double s)
          {
             monthlyHours = m;
             subType = s;
          }
     
       //Get hours used for month
          public double getHours()
          {
             return monthlyHours;
          }
     
       //Set hours used for month
          public void setHours(double m)
          {
             monthlyHours = m;
          }
     
       //Set and calculate hours for package A
          public void setCostOfA(double hours)
          {
             subAHours = hours - 10;
             subA = (subAHours * 1.99) + 9.95;
          }
     
       //Get Cost of Package A
          public double getCostOfA()
          {
             return subA;
          }
     
       }


    Once again, thank you for the help!


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,318
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: cannot find symbol in reference variable

    Only the constructor...
    public InternetAccount(double m, double s)
    ...is defined in the class InternetAccount, so the compiler cannot find the constructor you are trying to use.

  3. The Following 2 Users Say Thank You to copeg For This Useful Post:

    javapenguin (November 1st, 2010), NPotter86 (November 1st, 2010)

  4. #3
    Junior Member
    Join Date
    Nov 2010
    Posts
    3
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: cannot find symbol in reference variable

    Thank you very much!

Similar Threads

  1. Help with Cannot Find Symbol Variable errors
    By skboone in forum What's Wrong With My Code?
    Replies: 3
    Last Post: October 20th, 2010, 10:52 AM
  2. 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
  3. Fitting a large primitive into a small reference variable
    By Phobia in forum Java Theory & Questions
    Replies: 15
    Last Post: October 23rd, 2009, 03:10 PM
  4. cannot find symbol variable radius?
    By noobish in forum What's Wrong With My Code?
    Replies: 4
    Last Post: October 4th, 2009, 10:29 AM
  5. Replies: 5
    Last Post: September 19th, 2009, 06:48 AM