(Sort students on grades) Rewrite Listing 8.2, GradeExam.java, to display students in decreasing order of the number of correct answers.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

(Sort students on grades) Rewrite Listing 8.2, GradeExam.java, to display students in decreasing order of the number of correct answers.

 

-ting 8.2 GradeExam.java
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
4
6
7
8
10
11
12
13
14
|/ Key to the questions
char[] koys = { 'D', 'B', 'D', 'C', 'C', 'D', 'A', 'E', 'A', 'D'};
15
16
17
|| Grade all answers
for (int i = 0; i < answers.1ength; i++) {
|/ Grade one student
int correctCount = 0;
for (int j = 0; j < answers[i].length; j++) {
if (answers[i][U) == keys[j])
correctCount++;
18
19
20
21
22
23
24
25
26
27
System.out.printin("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 1s 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
Transcribed Image Text:-ting 8.2 GradeExam.java 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 4 6 7 8 10 11 12 13 14 |/ Key to the questions char[] koys = { 'D', 'B', 'D', 'C', 'C', 'D', 'A', 'E', 'A', 'D'}; 15 16 17 || Grade all answers for (int i = 0; i < answers.1ength; i++) { |/ Grade one student int correctCount = 0; for (int j = 0; j < answers[i].length; j++) { if (answers[i][U) == keys[j]) correctCount++; 18 19 20 21 22 23 24 25 26 27 System.out.printin("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 1s 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
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Program on Numbers
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education