Question: Create a class named State that holds the following fields: a String for the name of the state, an integer for the population, and two
Create a class named State that holds the following fields: a String for the name of the state, an integer for the population, and two City objects that hold data about the capital city and the most populous city. The State constructor requires six parameters that represent the names and populations of the state, its capital, and its most populous city. Provide get methods for each field. Create the City class to be a nonstatic, private inner class within the State class; the City class contains a citys name and population. Create a class to assign values to and display values from two State objects. Save the files as State.java and TestState.java.
The program output should look exactly like the example below. x 6. Command Prompt D:\JavaBatchFile>javac State.java D:\JavaBatchFile>javac TestState.java D:\JavaBatchFile>java TestState State: Illinois Population: 13000000 Capital: Springfield Population : 116000 Most populous city: Chicago Population: 7000000 State: Wisconsin Population: 570000 Capital: Madison Population: 230000 Most populous city: Milwaukee Population: 595000 D:\JavaBatchFile>. IT
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
