Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

Error with homework. Completely stuck.

$
0
0
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?

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>