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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started