Reorder the following program statements so that they define
Re-order the following program statements so that they define the printHiLow() method that takes an unsorted array of names and another array of associated scores, and then prints out the names and scores together, ordering them from the highest to the lowest score, which means to sort them by score. For instance if the following arrays were passed to this method:
Then the following would be printed out by the method:
Just re-order the lines. You don\'t have to add any lines. The entire method is already there:
Solution
HI,
I have reordered the lines below
String [] names = { \"Joe\", \"Jane\", \"Julie\" };
double [] scores = { 35.0, 95.0, 75.0 };
String [] sortArray = new String[names.length];
for (String str : sortArray)
System.out.println(str.substring(6));
for (int i = 0; i < names.length; ++i)
sortArray[i] = String.format(\"%.1f\",scores[i]) + \": \" + names[i] + \": \" + String.format(\"%.1f\",scores[i]);
public static void printHiLow(String[] names, double[] scores) {
Arrays.sort(sortArray, Collections.reverseOrder());
}
