This program will implement a rudimentary phone book, storing the first name, last name, and phone number for each person in the phone book. The "phonebook" will be stored in a 10×3 array of String s, with the first column storing first names, the second column storing last names, and the third column storing the phone number. Here is an example of how the array might look for a 4×3 phonebook: Column 0 Column 1 Column 2 Row 0 "Wanda" "Maximoff" "513-222-3333" Row 1 "Jean" "Grey" "111-2222" Row 2 "Peter" "Quill" "4021110000" Row 3 "Professor" "X" "x612" Row 4 "Black" "Widow" "none" The first and last names will always be a single "word", and the phone number in column 2 can be in any format. Program 11 – Spring 2018 Overview of Assignment All eight methods must be implemented as named and as described in order for Web-CAT to be able to test and score them correctly. You may not make any assumptions regarding the number of entries of the 2-D book arrays passed to these methods. That is, it may have any number of rows, but will always have three columns. (This allows for future expansion of your code.) 1. public static void initBook(String[][] book) This method will set every element of the array parameter book to an empty string "" , initializing the phone book array to a default state that has no entries in it. 2. public static boolean bookEmpty(String[][] book) This method will return true if the phone book is empty, false otherwise. Must handle null s 3. public static void displayBook(String[][] book) This method will display each entry in the format #. LAST, FIRST (PHONE) , where # is the row in the phonebook array, LAST is the person's last name, FIRST is the person's first name and PHONE is the person's phone number. If there are no entries in the book, display No entries. instead. 4. public static int findEmpty(String[][] book) This method will return an int value corresponding to the first "empty" position located in the array, starting from row 0 . If the array is full (i.e., all rows have an entry), return -1 . Must handle null s 5. public static void addEntry(String[][] book, Scanner g) If there is an empty/available row, this method will add a new entry to the phone book, asking for first name, then last name, then phone number. Otherwise, the display Phonebook is full! . 6. public static void deleteEntry(String[][] book, Scanner g) If there are no entries in the phonebook, the message No entries. should be displayed. Otherwise, the phonebook should be displayed and then the user can select a number from 0 through 9 to delete that entry in the phonebook, any other number to cancel. No data validation is necessary. Deleting an entry means that the first name, last name, and phonebook are all set to an empty string "" . It will display Record deleted. or No record deleted. as appropriate. 7. public static void sortBook(String[][] book) This method will sort the phonebook entries by last name. You can either implement a bubble sort or a selection sort for this. See "Points to Think About" for information about duplicate last names. The prompt Phonebook sorted. will always display to the screen. 8. public static void menu(String[][] book, Scanner g) This method displays a menu and calls the appropriate methods. This method has been provided for you. Public Methods the Program Must Provide Using String methods on String data stored in an array requires the specification of the element you're trying to access before using a method like .length() , .charAt() , .equals() , etc. public class StringMethodsInArrays { public static void main ( String[] args ) { // declare a 2-D array of Strings String[][] test = new String[2][3]; // Fill the first row test[0][0] = "Hello"; test[0][1] = "there"; test[0][2] = "world!"; // Fill the second row test[1][0] = "Supercalifragilisticexpealidocious"; test[1][1] = "Java Strings"; test[1][2] = "Hello"; // Output the length of "Supercalifragilisticexpealidocious" System.out.println( test[1][0].length() ); // Test two cells for equal String data if (test[0][0].equals(test[1][2]) { /* do something useful here */ } // See if test[1][1] comes alphabetically before test[0][1] if (test[1][1].compareTo(test[0][1]) { /* do something useful */ } } } As with previous programs, you will want to utilize a private static Scanner variable in this program. Notice that you must instantiate the Scanner in the main method and, for this program, pass that Scanner to other methods. The provided menu() method will demonstrate how this can be done. Using String data in arrays Using a global private static Scanner Utilize a 2-D array of String data to implement a phonebook application. Understand and extend searching and sorting algorithms to 2-D arrays. Starter code is provided! Please download the starter code from Canvas before you begin. Your class is names Phonebook . When sorting the array, take care to swap all of the relevant data from one location to another. For instance, a bubble sort on a 1-D array simply needs to swap two adjacent values if they are out of order. For this program, when your program identifies entries that need to be swapped, the code will need to swap the first and last names along with the phone number. If there are empty entries in the phonebook, when you sort the array the empty entries will sort to the front of the array. If there are multiple entries that have the same last name, you do not need to worry about sorting the first names; you may leave them in the order they are encountered in the array. The provided main() method shouldn't need to be modified. In order to use the Scanner correctly, it needs to be passed as an argument to each method. This is modeled in the call to the menu() method. An entry is considered to be "empty" if all three columns/fields in a row are equal to an empty string "" . The findEmpty() method should determine a new "empty" entry starting at position 0 in the array. Web-CAT expects to find all of the seven methods above plus your main() method when it compiles. To prevent errors and allow for testing earlier you can 'stub out' the methods. This usually involves writing the method signature and block and simply returning a dummy value such as 0 for numbers, false for booleans, '!' for char values, and "test" or some other short message for String return values. You can then write the logic and pass the tests on Web-CAT on a per-method basis, rather than all-or-nothing. Check out the sample run at the end of the assignment for an example. Remember that the jGRASP Interactions tool is very useful for testing the individual methods without having to implement all of the supporting code. Directions are provided in the previous assignment for using this tool. Goals Class and File Naming Points to Think About Testing Your Program You must have a signed Collaboration document on file for the course in order for this program to be graded. Every method you write must have Javadoc documentation describing it. You must write seven additional methods for this program, all named and implemented as described earlier in the assignment. Your program must have a global public static Scanner that you utilize throughout your program. In other words, you can only have a single Scanner for the entire program. It must be initialized within main() . You can only have a global Scanner and may not have any other variables declared outside of methods. All other data values must be passed via arguments to methods and returned with return statements. You may only use material through lecture 22 of the class and the String data type for this program. Using material beyond lecture 22 is not acceptable. NOTE: If your submitted assignment does not compile, you will receive 0 points. We are unable to test code that does not compile. Insuring that your code compiles is critical when developing programs. We would rather grade an incomplete yet operational program than a program that we can't test. Item Points Notes Style/Coding (WebCAT): Documentation/style of source code 7 Have header documentation that includes your name and other relevant information and javadoc for all methods. Meets expectations in CIST1400-checkstyle_intermediate.xml . Design/Readability (GA): Useful variable names 3 Consistently use descriptive variable names, and code is well thought out. Correctness/Testing: MethodXX() testing 27 Follow expected method signatures (numbered 1 – 7 as above) and output as shown in Sample runs. Correctness/Testing: Main() testing 3 Main program appears and behaves as expected. Grading Notes Grading Rubric Phonebook Main Menu 1. Display Phonebook 2. Add Entry 3. Delete Entry 4. Sort Book 9. Quit Enter choice: 1 No entries. 1. Display Phonebook 2. Add Entry 3. Delete Entry 4. Sort Book 9. Quit Enter choice: 3 No entries. 1. Display Phonebook 2. Add Entry 3. Delete Entry 4. Sort Book 9. Quit Enter choice: 2 Enter first name : Alexander Enter last name : Hamilton Enter phone number: 111-222-1776 1. Display Phonebook 2. Add Entry 3. Delete Entry 4. Sort Book 9. Quit Enter choice: 1 Sample Run 0. Hamilton, Alexander (111-222-1776) 1. Display Phonebook 2. Add Entry 3. Delete Entry 4. Sort Book 9. Quit Enter choice: 4 Phonebook sorted. 1. Display Phonebook 2. Add Entry 3. Delete Entry 4. Sort Book 9. Quit Enter choice: 3 9. Hamilton, Alexander (111-222-1776) Enter number of entry to delete, any other integer value to cancel: 5 No record deleted. 1. Display Phonebook 2. Add Entry 3. Delete Entry 4. Sort Book 9. Quit Enter choice: 2 Enter first name : Maurice Enter last name : Hamilton Enter phone number: 111-222-1776 1. Display Phonebook 2. Add Entry 3. Delete Entry 4. Sort Book 9. Quit Enter choice: 1 0. Hamilton, Maurice (111-222-1776) 9. Hamilton, Alexander (111-222-1776) 1. Display Phonebook 2. Add Entry 3. Delete Entry 4. Sort Book 9. Quit Enter choice: 4 Phonebook sorted. 1. Display Phonebook 2. Add Entry 3. Delete Entry 4. Sort Book 9. Quit Enter choice: 1 8. Hamilton, Maurice (111-222-1776) 9. Hamilton, Alexander (111-222-1776) 1. Display Phonebook 2. Add Entry 3. Delete Entry 4. Sort Book 9. Quit Enter choice: 2 Enter first name : Lin-Manuel Enter last name : Miranda Enter phone number: 111-222-2015 1. Display Phonebook 2. Add Entry 3. Delete Entry 4. Sort Book 9. Quit Enter choice: 1 0. Miranda, Lin-Manuel (111-222-2015) 8. Hamilton, Maurice (111-222-1776) 9. Hamilton, Alexander (111-222-1776) 1. Display Phonebook 2. Add Entry 3. Delete Entry 4. Sort Book 9. Quit Enter choice: 4 Phonebook sorted. 1. Display Phonebook 2. Add Entry 3. Delete Entry 4. Sort Book 9. Quit Enter choice: 1 7. Hamilton, Maurice (111-222-1776) 8. Hamilton, Alexander (111-222-1776) 9. Miranda, Lin-Manuel (111-222-2015) 1. Display Phonebook 2. Add Entry 3. Delete Entry 4. Sort Book 9. Quit Enter choice: 2 Enter first name : Aaron Enter last name : Burr Enter phone number: x1 1. Display Phonebook 2. Add Entry 3. Delete Entry 4. Sort Book 9. Quit Enter choice: 1 0. Burr, Aaron (x1) 7. Hamilton, Maurice (111-222-1776) 8. Hamilton, Alexander (111-222-1776) 9. Miranda, Lin-Manuel (111-222-2015) 1. Display Phonebook 2. Add Entry 3. Delete Entry 4. Sort Book 9. Quit Enter choice: 3 0. Burr, Aaron (x1) 7. Hamilton, Maurice (111-222-1776) 8. Hamilton, Alexander (111-222-1776) 9. Miranda, Lin-Manuel (111-222-2015) Enter number of entry to delete, any other integer value to cancel: 7 Record 7 deleted: Hamilton, Maurice (111-222-1776) 1. Display Phonebook 2. Add Entry 3. Delete Entry 4. Sort Book 9. Quit Enter choice: 1 0. Burr, Aaron (x1) 8. Hamilton, Alexander (111-222-1776) 9. Miranda, Lin-Manuel (111-222-2015) 1. Display Phonebook 2. Add Entry 3. Delete Entry 4. Sort Book 9. Quit Enter choice: 9

 

Doing a similar assignment? Save your time and hire our Genuine Essay Writers to do your task. Get 15% Discount on your 1st order. Use code: FREE15