Import modules and declare variables and also Print instructions Read in phone b
ID: 3534749 • Letter: I
Question
- Import modules and declare variables and also Print instructions
- Read in phone book file
- Create file
- Create scanner for file
- Determine number of entries
- Read each entry:
- Put names in a name array
- Put phone numbers in a number array
- Figure out if user wants to search via name or number
- Sort both arrays using the appropriate method (both are provided for you)
- sortByNames if user wants to search using a name
- sortByNumbers if user wants to search using a number
- Perform a binary search on the appropriate array
- Pick low bound to zero high bound to size of the array
- look until query is found or nowhere else to look
- set the current position to half way between low and high
- store the current position and stop if we have the right answer
- check if we are too low or too high
- adjust the appropriate bound to shrink the search area
- If we found our search query: print the corresponding name and number at that position
- If not: inform the user their search did not yield any results
- Ask the user if they would like to search again or quit
Explanation / Answer
I can do this contact me on timacs12@gmail.com. you can rate me after getting the answer