Question: Rewrite Listing 8.2, GradeExam.java, to display the students in increasing order of the number of correct answers. Listing 1 public class GradeExam { 2 /**
Rewrite Listing 8.2, GradeExam.java, to display the students in increasing order of the number of correct answers.
Listing

![void main(String[] args) { // Students' answers to the questions char[][] answers](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2022/11/636a72ba9424c_570636a72ba841dd.jpg)
1 public class GradeExam { 2 /** Main method */ public static void main(String[] args) { // Students' answers to the questions 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'}}; 3 5 10 11 12 13 14 15 16 17 18 19 20 // Key to the questions char[] keys = {'D', 'B', 'D', 'C', 'C', 'D', 'A', 'E', 'A', 'D'}; // Grade all answers for (int i = 0; i < answers.length; i++) { // Grade one student int correctCount = 0; for (int j = 0; j < answers[i].length; j++) { if (answers [i][j] == keys [j]) correctCount++; 21 22 23 24 25 26 27 System.out.println("Student" +i+ "'s correct count is correctCount); 28 29 30 31 } Student 0's correct count is 7 Student 1's correct count is 6 Student 2's correct count is 5 Student 3's correct count is 4 Student 4's correct count is 8 Student 5's correct count is 7 Student 6's correct count is 7 Student 7's correct count is 7
Step by Step Solution
3.46 Rating (178 Votes )
There are 3 Steps involved in it
Header section import class declartion class Begin ... View full answer
Get step-by-step solutions from verified subject matter experts
