Question: Write your code in the file CellPhoneBook.java. CellPhoneBook is a user's cellphone number directory. The user can enter the names of his or her acquaintances
Write your code in the file CellPhoneBook.java.
CellPhoneBook is a user's cellphone number directory. The user can enter the names of his or her acquaintances and their cellphone numbers, and later he or she can look up a particular person's phone number when needed.
We have written part of the program for you already. The program you are given inputs the maximum number of entries the phone book can hold, then displays a menu to the user. You will complete the program by doing the following:
adding any needed variables and initializing them
writing code to respond to each of the menu options
Complete the following menu options of CellPhoneBook. You may write additional methods if you wish.
Add entry
inputs: contact's name (string), contact's phone number (string)
outputs: success/failure (boolean)
Put the given entry into the phone book. Output true if successful. This method should run in O(1) time. You do not have to check for duplicate entries.
Delete entry
inputs: contact's name (string)
outputs: success/failure (boolean)
Remove the given entry from the phone book. Output true if successful. Finding the entry may take up to O(n) time where n is the number of entries. However, after finding the entry, deleting it should take O(1) time. You do not have to check for duplicate entries.
Lookup cell number
inputs: contact's name (string)
outputs: contact's phone number (string)
Retrieve the cellphone number recorded for the person with the given name. If no entry for that person exists, output null. Use binary search if possible, and sequential search if not.
Change cell number
inputs: contact's name (string), contact's new phone number (string)
outputs: success/failure (boolean)
Change the cellphone number for the given person to the specified new number. Output true if successful. Use binary search if possible, and sequential search if not.
Sort entries
inputs: none
outputs: names and phone numbers in alphabetical order (strings)
Sort the entries in the given phone book alphabetically by name, and display them. Use quicksort.
Remember to test each of your menu options thoroughly.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
