Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

USE THE ABOVE CODE IN YOURS ANSER ( ANY ONE OF 2) THERE SHOULD BE NO INPUT NEEDE

ID: 3846184 • Letter: U

Question

USE THE ABOVE CODE IN YOURS ANSER ( ANY ONE OF 2) THERE SHOULD BE NO INPUT NEEDED

This assignment is the first in-class assignment dealing with single- and multi-dimensional arrays, specifically, to grade student exams using a single-dimensional array to hold the answer key and a multi-dimensional array to hold the students' answers. You need to complete this assignment prior to doing part 2. For today: Create a class to grade student responses to a multiple choice test. You will create a single-dimensional array for the answer key and a multi (two)-dimensional array to hold the students' answers For simplicity, make the answer key a charll and the student answers a charlJU. To instantiate and initialize them, use the curly brace notation. [See the sample code fragments to save some typing.] The data for the answer key is: Question number (index) 0 1 2 3 4 5 6 7 8 9 Correct answer D B D C C D A E A D The data for the student answers is: 0 1 2 3 4 5 6 7 89 Question number (index) Student A B A C C D E E A D Student 1 D B A B C A E E A D Student 2 E D D A C B E E A D Student 3 C B A E D C E E A D Student 4 A B D C C D E E A D Student 5 B B E C C D E E A D Student 6 B B A C C D E E A D Student 7 E B E C C D E E A D Your program should not do any input/prompting. The output is mostly up to you but it should reflect each student's grade, the success rate for each question or both. Remember: Use mnemonic variable names even for loop variables You may create utility methods but it is not required. No error checking is required all data is valid

Explanation / Answer

Here is the code for the question. Please don't forget to rate the answer if it helped. Thank you very much.

In case you need any clarification, please drop a comment and I shall respond.

public class StudentGrade {

   public static void main(String[] args) {

       char[] answerKeyFromChars = { 'D', 'B', 'D', 'C', 'C', 'D', 'A', 'E', 'A', 'D' } ;

char[][] studentsAnswersFromChars =

{ { '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' }

} ;

  

//to count the number of correct answers for each question

int[] correcAnswersCount = new int[answerKeyFromChars.length];

  

//array to hold score of each student

int[] studentScore = new int[studentsAnswersFromChars.length];

  

  

//calculate the score for each student by matching their answers to key

for(int student=0; student < studentsAnswersFromChars.length; student++)

{

   for(int answer = 0; answer < studentsAnswersFromChars[student].length; answer++)

   {

       if(studentsAnswersFromChars[student][answer] == answerKeyFromChars[answer])

       {

           studentScore[student] ++;

           correcAnswersCount[answer]++;

       }

       

   }

}

  

double percentage;

char grade;

//grade each student based on their percentage score

for(int student = 0; student < studentScore.length; student++)

{

   percentage = studentScore[student] * 100.0 /answerKeyFromChars.length;

   if(percentage >= 90)

       grade = 'A';

   else if(percentage >= 80)

       grade = 'B';

   else if(percentage >= 70)

       grade = 'C';

   else if (percentage >=60)

       grade = 'D';

   else

       grade = 'E';

      

      

   System.out.println("Student "+student+" Percentage: "+ percentage + " Grade: "+grade);   

}

  

for(int answer=0; answer < correcAnswersCount.length; answer++)

{

   percentage = correcAnswersCount[answer] * 100.0 / correcAnswersCount.length;

   System.out.println("Question "+answer+" No.Correct Answers: "+correcAnswersCount[answer]+" Success %: "+percentage);

}

   }

}

output

Student 0 Percentage: 70.0 Grade: C

Student 1 Percentage: 60.0 Grade: D

Student 2 Percentage: 50.0 Grade: E

Student 3 Percentage: 40.0 Grade: E

Student 4 Percentage: 80.0 Grade: B

Student 5 Percentage: 70.0 Grade: C

Student 6 Percentage: 70.0 Grade: C

Student 7 Percentage: 70.0 Grade: C

Question 0 No.Correct Answers: 1 Success %: 10.0

Question 1 No.Correct Answers: 7 Success %: 70.0

Question 2 No.Correct Answers: 2 Success %: 20.0

Question 3 No.Correct Answers: 5 Success %: 50.0

Question 4 No.Correct Answers: 7 Success %: 70.0

Question 5 No.Correct Answers: 5 Success %: 50.0

Question 6 No.Correct Answers: 0 Success %: 0.0

Question 7 No.Correct Answers: 8 Success %: 80.0

Question 8 No.Correct Answers: 8 Success %: 80.0

Question 9 No.Correct Answers: 8 Success %: 80.0