import javax.swing.JOptionPane;
public class Pract {
public static void main(String[] args) {
char[][] answers = {
{'A', 'B', 'A', 'C', 'C', 'D', 'E', 'E', 'A', 'D'},
{'D', 'B', 'A', 'B', 'C', 'A', 'E', 'E', 'A', 'D'},
{'E', 'D', 'D', 'A', 'C', 'B', 'E', 'E', 'A', 'D'},
{'C', 'B', 'A', 'E', 'D', 'C', 'E', 'E', 'A', 'D'},
{'A', 'B', 'D', 'C', 'C', 'D', 'E', 'E', 'A', 'D'},
{'B', 'B', 'E', 'C', 'C', 'D', 'E', 'E', 'A', 'D'},
{'B', 'B', 'A', 'C', 'C', 'D', 'E', 'E', 'A', 'D'},
{'E', 'B', 'E', 'C', 'C', 'D', 'E', 'E', 'A', 'D'}};
char[] keys = {'D', 'B', 'D', 'C', 'C', 'D', 'A', 'E', 'A', 'D'};
int[] student = new int[8];
//Create new array to sort students
String studentSort = "The list of students in order: \n" + "\n";
for (int x = 0; x < 8; x++) {
studentSort += student[x] + " \n"; // this code is incorrect and is not necessary -> ERASE
} // You are just entering 0's into the array, not the value of anything meaningful
// Which is why are you displaying zeros
//Echo the answers
String result = "The answer key to the test: \n";
for (int k = 0; k < 10; k++) {
result += keys[k] + " ";
}
for (int i = 0; i < answers.length; i++) {
int correctCount = 0;
//Convert grades to a String
String result2 = "Student " + i + "'s answers are: \n";
for (int j = 0; j < answers[i].length; j++) {
result2 += answers[i][j] + " ";
if (answers[i][j] == keys[j])
correctCount++;
student[i] = correctCount;
}
//Display the input
JOptionPane.showMessageDialog(null, result + "\n" + result2 + // Leave this code here to display
"\nStudent " + i + "'s correct count is " + correctCount);
} // Here, add 1 to i -> (i + 1) because there is no student 0...
// Here you want to sort the array, I think I remember helping you with a bubble sort algorithm so this shouldn't be too hard.
// YOU ARE NOT SORTING THE ARRAY, THIS IS WHERE TO SORT THE ARRAY
// Sort the array "student", and then enter the results into a string
JOptionPane.showMessageDialog(null, studentSort);
}
}