Question: This problem is from programming assignment 8 in the chapter 6 on Arrays. In this exercise you should create parallel arrays. That means creating multiple

This problem is from programming assignment 8 in the chapter 6 on Arrays.

In this exercise you should create parallel arrays. That means creating multiple arrays where the elements in certain positions each array is synchronized with elements in the same position in other arrays.

Design and code a program to read data from a data file into two separate parallel arrays One array will contain a list of the names of the states in the U.S. and another array will contain a list of names of the state capital cities corresponding / matching the states. In the module for Arrays and Text File Processing, there is a list of text data files. The text data file, named capitals.txt contains a list of states and capitals, with a state name on one line followed by a capital city name on the next line, such as: Alabama followed by Montgomery, Alaska followed by Juneau, Arizona followed by Phoenix, and Arkansas followed by Little Rock. Here are the requirements of the program.

The program should first load the data from the text file into the two arrays. Your application should read the state names into one array and the matching capital city names into the second parallel array. I recommend printing out the elements in each array after they are loaded to verify that the data was loaded correctly and entirely.

After the data is loaded, your program should randomly pick a state in the state array. Your program should then tell the user the name of the state. The program should prompt the user for name of the capital of the state displayed. After the users enters their guess of the state capital, the program should verify that the state capital entered is in the parallel state capitol array. If the capitol name is found, the program should then verify that the capital entered matches the state that was displayed to the user.

Use the capitals.txt file in the module for arrays. Design your program to read the states and capitals data from this file. You should copy this file to the project folder of the assignment. It will prevent you from needing to write a long path name in your program to point to and access the file on your system. Additionally, when you submit your assignment the data that you used will be transported with the project.

This problem is from programming assignment 8 in the chapter 6 on

This problem is from programming assignment 8 in the chapter 6 on Arrays. In this exercise you should create parallel arrays. That means creating multiple arrays where the elements in certain positions each array is synchronized with elements in the same position in other arrays. Design and code a program to read data from a data file into two separate parallel arrays-One array will contain a list of the names of the states in the U.S. and another array will contain a list of names of the state capital cities corresponding matching the states. In the module for Arrays and Text File Processing, there is a list of text data files. The text data file named capitals.txt contains a list of states and capitals, with a state name on one line followed by a capital city name on the next line, such as: Alabama followed by Montgomery, Alaska followed by Juneau, Arizona followed by Phoenix, and Arkansas followed by Little Rock. Here are the requirements of the program The program should first load the data from the text file into the two arrays. Your application should read the state names into one array and the matching capital city names into the second parallel array. I recommend printing out the elements in each array after they are loaded to verify that the data was loaded correctly and entirely. After the data is loaded, your program should randomly pick a state in the state array. Your program should then tell the user the name of the state. The program should prompt the user for name of the capital of the state displayed. After the users enters their guess of the state capital, the program should verify that the state capital entered is in the parallel state capitol array. If the capitol name is found, the program should then verify that the capital entered matches the state that was displayed to the user. Use the capitals.txt file in the module for arrays. Design your program to read the states and capitals data from this file You should copy this file to the project folder of the assignment. It will prevent you from needing to write a long path name in your program to point to and access the file on your system. Additionally, when you submit your assignment the data that you used will be transported with the project. Submit your programming assignment as Zipped NetBeans Project Folder

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!