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.
Download the employee data file and place it in the folder with your code. File here: employee_data.csv
Create a method called loadData, which reads the employee data from the file. You will need to use split to separate the data and place it into a series of arrays (employeeIds, employeeNames, etc.)
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.
/*** * 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; }