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: Cannot find symbol. Completely Stuck

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

    Default Cannot find symbol. Completely Stuck

    So I have a project that asks me to make a class called CityInfo and put different methods in it to set a city, state, year, population, and area. It then calculates density and annual growth. This program does not print anything so I have to use the 'Interactions' tab in JGrasp. My other code is CityInfoApp, it gets user input for the different methods and actually prints it out. However i have a small problem, it wont compile due to some error that I have honestly no idea how to fix. Here is CityInfoApp.



    public class  CityInfoApp
     
    {
     
       public static void main(String[] args)
     
       {
     
          int fYear, iPop, pop;
     
          double area, den, growth;
     
          String city, state, name;
     
          CityInfo aub;
     
          Scanner stdInReader = new Scanner(System.in);
     
     
     
        // get user input for city and state
     
          System.out.print("City: ");
     
          city = stdInReader.nextLine();
     
          System.out.print("\nState: ");
     
          state = stdInReader.nextLine();
     
     
     
        // get user input for founded year, initial population, population
     
          System.out.print("\nYear founded: ");
     
          fYear = stdInReader.nextInt();
     
          System.out.print("\nInitial Population: ");
     
          iPop = stdInReader.nextInt();
     
          System.out.print("\nPopulation: ");
     
          pop = stdInReader.nextInt();
     
     
     
        // area
     
          System.out.print("\nArea: ");
     
          area = Double.parseDouble(stdInReader.nextLine());
     
     
     
          // in the line below, replace the blank with your name
     
          aub = new CityInfo(name);
     
          /*
     
          */
     
     
     
          // set the year founded
     
          aub.setYear(fYear);
     
     
     
          // set the initial population
     
        aub.setInitialPopulation(iPop);
     
        // set current population
     
        aub.setPopulation(pop);
     
          //set area
     
          aub.setArea(area);
     
     
     
     
     
     
     
        // print
     
          System.out.print("City: " + city + ", " + state
     
             + " (Founded in " + fYear + ")"
     
             + "\nPopulation: " + pop
     
             + "\nArea: " + area
     
             + "\nDensity: " + aub.Density() + " people per sq mi"
     
             + "\nGrowth: " + aub.annualGrowth() + " people per yr");
     
     
     
       }
     
    }



    The line aub = new CityInfo(name);
    does not work because it "cannot fin symbol" and is pointing at 'new'. What is my problem?


  2. #2
    Super Moderator curmudgeon's Avatar
    Join Date
    Aug 2012
    Posts
    1,130
    My Mood
    Cynical
    Thanks
    64
    Thanked 140 Times in 135 Posts

    Default Re: Cannot find symbol. Completely Stuck

    Hello and welcome to the javaprogrammingforums. You may have noticed that your posted code is hard to read. I recommend that you have a look at the forum FAQ's about how to use code tags, and then press the "Edit Post" link on the bottom of your post, remove your current code, paste in well-formatted code without line numbers and using code tags.

    Good luck!

  3. #3
    Member
    Join Date
    Jan 2013
    Posts
    34
    My Mood
    Busy
    Thanks
    2
    Thanked 4 Times in 4 Posts

    Default Re: Cannot find symbol. Completely Stuck

    I really don't understand how there could be an error.
    Are you saying
    aub = new CityInfo(name);
    gets an error? I'm sorry I don't understand why the error is happening.
    Just check your CityInfo class again, good luck on the project!

  4. #4
    Super Moderator curmudgeon's Avatar
    Join Date
    Aug 2012
    Posts
    1,130
    My Mood
    Cynical
    Thanks
    64
    Thanked 140 Times in 135 Posts

    Default Re: Cannot find symbol. Completely Stuck

    We will need:
    1. The *full* error message. Every little bit of that message is critical.
    2. You will need to post the CityInfo class code, especially its constructor.
    3. Does this class in fact have a constructor that takes a String?

Similar Threads

  1. cannot find symbol
    By lanpan in forum What's Wrong With My Code?
    Replies: 1
    Last Post: February 1st, 2012, 08:13 AM
  2. Cannot find Symbol?
    By defmetalhead in forum What's Wrong With My Code?
    Replies: 8
    Last Post: July 5th, 2011, 08:48 AM
  3. completely stuck on a simple code
    By disp in forum Loops & Control Statements
    Replies: 6
    Last Post: June 30th, 2011, 12:02 PM
  4. Help!, newbie, interested in Java, Very simple code, completely stuck!
    By munkybunky in forum What's Wrong With My Code?
    Replies: 4
    Last Post: June 30th, 2011, 07:25 AM
  5. School java project, completely stuck
    By John1818 in forum Java Theory & Questions
    Replies: 0
    Last Post: November 18th, 2010, 04:10 AM