Lab Assignment
We must create a program that will print a sorted list of all the students and the corresponding scores listing the highest score first and the lowest score last. In this case I would need a Bubble Sort.
Question
This is my "Bubble Sort" method shown in the code block below.
public static void bubbleSort(String [] name, double [] score)
{
double temp;
int counter;
int index = 0;
for(counter = 0; counter < score.length - 1 - counter; index++)
{
if(score[index] > score[index + 1])
{
temp = score[index];
score[index] = score[index + 1];
score[index + 1] = temp;
}
}
}
Looking at the way I have written this code I did not use the String [] name array in the method so the names will not be sorted along side the corresponding exam score.
How would i fix this code to sort not only the scores but print the names that go along side the scores? Do I need another method to accpet the names?