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.
The line
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?