193k views
4 votes
Create a JavaFX GUI program that allows a user to input the name of a state and display the state capital and population for that state.

When the program starts, it should first
READ and load the data
Open the data file (download attached file) and read the data. Create a StateCapital object for each capital and add it to a Map. Close the data file.
You will need to create a class called StateCapital consisting of the following data
- city
- state
- population
Include a constructor, accessor and mutator methods for each data members
Override the toString method
StateCapitals.txt
i keep getting these errors please help
or provide new code

1 Answer

5 votes

Final answer:

The student is experiencing issues with JavaFX code to display state capitals and populations. They need to create a StateCapital class, read the contents of a file into a Map, and then use JavaFX components for the GUI.

Step-by-step explanation:

The student is asking for help with a JavaFX GUI program to input a state name and display its capital and population. To address the errors the student is facing, one has to view the actual error messages. However, we can provide a general guide to how one could go about creating such a program without seeing the specific errors.


To create the program, firstly, a StateCapital class should be defined, with the required data members: city, state, population, and corresponding constructor, accessors (getters), and mutators (setters). After completing the StateCapital class, read the data from the file 'StateCapitals.txt' and store each entry into a Map for easy access. The JavaFX GUI should include a text field for user input, a button to trigger the search, and labels or text areas to display the results. The toString method in the StateCapital class should be overridden to provide a formatted output of the state capital's data when it is requested.

User Deta Utama
by
7.9k points