Question: Pre-Lab: You will write a program that will allow the user to search the United States by state Abbreviation, Name, and Capital. Please review the

Pre-Lab:

You will write a program that will allow the user to search the United States by state Abbreviation, Name, and Capital. Please review the Powerpoints "File Input w/ Arrays" and "Linear and Binary Search". Download the attached states.txt into your working folder.

Part One:
Create a class called State.java.
Data fields include name, abbreviation and capital.
Write a 3-arg constructor.
Write accessor methods for each of the data fields.
Write a to String method. Use " " if you want the returned string to appear on multiple lines.
 
Part Two:

Create a class called StateFinder.java. Create an array of State objects, size 51. Fill the array using a file-reading Scanner. Close the Scanner after you finish filling the array. Use a while loop to present a menu of choices allowing the user to search by name, abbreviation, or capital. Name should be found using a binary search (do this using methods similar to those shown in Power point). Abbreviation and capital should be found using a linear search. Please use ONE method for linear search. To do so, pass in an integer argument to the search method to indicate which data field is being searched. For example, 1 for abbreviation and 2 for capital.

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!