Using two classes, create a Java program that instantiates three State objects. Your program will prompt the user to enter the names and populations of three states, which are then stored in the...

Hello, can you help me with this please??
Using two classes, create a Java program that instantiates three State objects. Your program will prompt<br>the user to enter the names and populations of three states, which are then stored in the fields of the<br>three State objects. The program will then retrieve this data from the objects, printing the names and<br>populations of each state.<br>State Class (State.java)<br>Must contain two fields:<br>O A String called stateName<br>o An int called population<br>A method named toString that returns a String containing the stateName and population fields.<br>o String to return:

Extracted text: Using two classes, create a Java program that instantiates three State objects. Your program will prompt the user to enter the names and populations of three states, which are then stored in the fields of the three State objects. The program will then retrieve this data from the objects, printing the names and populations of each state. State Class (State.java) Must contain two fields: O A String called stateName o An int called population A method named toString that returns a String containing the stateName and population fields. o String to return: "State Name: stateName. Population: population." StateDemo Class (StateDemo.java) This is the class that will demo the State objects; thus, it contains the main method. In the main method: Construct three instances of State objects Prompt the user to enter the name and population for a state. o Store the name and population to one of the three State objects. o Prompt the user to enter the name and population of two more states, storing the name and population of each to their own State object. Print the name and population of each state using the toString method of each State object. Be sure to use comments to document your code. Sample Input/Output Please enter the first state: Pennsylvania Please enter the first state's population: 12702379 Please enter the second state: New Jersey Please enter the second state's population: 8791894 Please enter the third state: Delaware Please enter the third state’s population: 897934 State Name: Pennsylvania. Population: 12702379. State Name: New Jersey. Population: 8791894. State Name: Delaware. Population: 897934.
Jun 08, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here