import java.io.*; public class exp // a class for timing experiments { private int[] A; // Create Test Data File: public void make_data(int nums, String filename) { int i; RandomAccessFile outfile; try { // must encapsulate IO outfile = new RandomAccessFile(filename, "rw"); for (i=0;i max) max = A[i]; return max; } public void bubblesort() // classic bubble sort algorithm { int i, j, temp; for(i=0;i A[j+1]) { temp = A[j]; A[j] = A[j+1]; A[j+1] = temp; } } public static void main(String[] args) { int i, j, max; long StartTime, ElapseTime, st2, et2; // not 'long' int nums = 1000; // change this to alter array size String file; // file name exp exp0; // the experiment object file = "nums" + nums; // file name is dependent on array size exp0 = new exp(); // create experiment object exp0.make_data(nums,file); // uncomment to make data file. exp0.read_data(nums,file); StartTime = System.currentTimeMillis(); exp0.bubblesort(); // find the maximum number ElapseTime = System.currentTimeMillis() - StartTime; st2 = System.currentTimeMillis(); exp0.print(); // print the array et2 = System.currentTimeMillis() - st2; System.out.println("Approximate time for bubblesort = " + ElapseTime + " milliseconds."); System.out.println("Approximate time to print = " + et2 + " milliseconds."); try {System.in.read();} catch (IOException e) {} // needed for PC's } }