Instructor: Todd Dole
This assignment gives further practice manipulating arrays, including arrays of strings and sorting. You will have two weeks to complete this assignment.
public static void printReport()Iterate through the EmployeeData variables and print a report, that looks similar to the following:
Employee ID Name Address Phone =========== =================== ============================================================= ============ 13 John Doe 1234 Mockingbird Lane, Abilene, TX 79605 325-555-1234 ... (more data here)Hint: You can use printf with codes like %10d to help with formatting. I have also included a helper class that will pad a string with spaces to the right to help with the formatting.
public static int[] sortedIds()
returns a copy of employeeIds with the numbers in sorted order
Hint #1: You can create a fresh copy of employeeId with the following code:
int[] copiedArray = originalArray.clone();(Think about why this is necessary -- what happens to your report if you sort employee Id's but leave names, addresses and phone numbers unchanged?)
Here is a helpful reference page on selection sort: https://www.geeksforgeeks.org/selection-sort-algorithm-2/
public static void sortEmployeeData()Use selection sort to sort all the employee data by employee Id. Note that we are now sorting the original variables rather than making copies.
Hint: Every time you swap two employee IDs, you will also need to swap the corresponding Name, Address and Phone Number so that all the data stays together.
Submit your working .java file through Canvas.
static int[] employeeIds = { 13, 25, 267, 592608, 592324, 2023001, 2024001, 2023007, 2022013, 2022014 } ; static String[] employeeNames = { "John Doe", "Jeremiah Smith", "Jennifer O'Conner", "Gretchen Hughes", "Lebron James", "Elizabeth Holsteader", "Kevin Hanson", "Zoe Bartholomew", "Sophia Lovejoy", "Lucas Lovejoy" }; static String[] employeeAddresses = { "1234 Mockingbird Ln, Abilene, TX 79605", "5678 Pine St, Abilene, TX 79601", "910 Cedar Ave, Abilene, TX 79603", "345 Elmwood Dr, Abilene, TX 79602", "789 Willow Ct, Abilene, TX 79606", "111 Oakridge Rd, Abilene, TX 79605", "222 Maple Ln, Abilene, TX 79601", "333 Lakeview Blvd, Abilene, TX 79606", "444 Sunflower Dr, Abilene, TX 79603", "444 Sunflower Dr, Abilene, TX 79603" }; static String[] employeePhoneNumbers = { "325-555-1234", "325-555-2345", "325-555-3456", "325-555-4567", "325-555-5678", "325-555-6789", "325-555-7890", "325-555-8901", "325-555-9012", "325-555-0123" }; /*** * rightPad(String start, int total_length) returns a copy of start with spaces added to the end, to make the total length * of the string equal to total_length. **/ public static String rightPad(String start, int total_length) { String newString = new String(start); for (int i=start.length(); i < total_length; i++) newString+=" "; return newString; }