/* SortEmployeeFile.java CIS 111 Dave Klick 2013-11-15 Reads in sequential file data into parallel arrays, sorts the data in the parallel arrays, and then displays the data. */ public class SortEmployeeFile extends CIS111App { public static void main(String[] args) { SequentialFile infile = new SequentialFile("emp.txt", FileMode.INPUT); int MAXSIZE = 1000; int numrecs = 0; int i, j; String[] name = new String[MAXSIZE]; String[] dept = new String[MAXSIZE]; double[] rate = new double[MAXSIZE]; // read records into parallel arrays while (!infile.eof()) { if (numrecs >= MAXSIZE) { println("Error: Too many employee records"); System.exit(1); } name[numrecs] = infile.readString(); dept[numrecs] = infile.readString(); rate[numrecs] = infile.readDouble(); numrecs++; } infile.close(); // sort records using parallel arrays for (i=0; i0 || (compDept==0 && compName>0)) { // swap names String temp = name[i]; name[i] = name[j]; name[j] = temp; // swap departments temp = dept[i]; dept[i] = dept[j]; dept[j] = temp; // swap rates double tempRate = rate[i]; rate[i] = rate[j]; rate[j] = tempRate; } } } // display sorted records println("Name Dept Rate"); println("---------- ------ -------"); for (i=0; i