Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import javax.swing.JOptionPane;
- public class GradeExam {
- 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'};
- //Create new array to sort students
- int[][] student = new int[8][8];
- //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 + 1) + "'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][0] = correctCount;
- student[i][1] = i;
- }
- //Display the input
- JOptionPane.showMessageDialog(null, result + "\n" + result2 +
- "\nStudent " + (i + 1) + "'s correct count is " + correctCount);
- }
- bubbleSortMulti(student);
- }
- public String[][] bubbleSortMulti(String[][] MultiIn, int compIdx) {
- String[][] temp = new String[MultiIn.length][MultiIn[0].length];
- boolean finished = false;
- while (!finished) {
- finished = true;
- for (int i = 0; i < MultiIn.length - 1; i++) {
- if (MultiIn[i][compIdx].compareToIgnoreCase(MultiIn[i + 1][compIdx]) > 0){
- for (int j = 0; j < MultiIn[i].length; j++) {
- temp[i][j] = MultiIn[i][j];
- MultiIn[i][j] = MultiIn[i + 1][j];
- MultiIn[i + 1][j] = temp[i][j]; }
- finished = false;
- }
- }
- }
- return MultiIn;
- }
- }
- ----jGRASP exec: javac -g GradeExam.java
- GradeExam.java:43: bubbleSortMulti(java.lang.String[][],int) in GradeExam cannot be applied to (int[][])
- bubbleSortMulti(student);
- ^
- 1 error
- ----jGRASP wedge2: exit code for process is 1.
- ----jGRASP: operation complete.
Add Comment
Please, Sign In to add comment