Answered! Java programming First, create a method to grade the student exams – gradeExams()…

Java programming

First, create a method to grade the student exams – gradeExams(). It takes 2 parameters: the answer key (single dimensional array) and the student answers (two dimensional array); displays the results; no return value (void). It should invoke a second method – gradeExam() that takes 2 parameters: the answer key (single dimensional array) and a single dimensional array for a single student’s answers; displays the results; no return value (void).

Don't use plagiarized sources. Get Your Custom Essay on
Answered! Java programming First, create a method to grade the student exams – gradeExams()…
GET AN ESSAY WRITTEN FOR YOU FROM AS LOW AS $13/PAGE
Order Essay

Once this works, create 2 more methods: getAnswerKey() and getStudentAnswers() which prompt the user for the corresponding information. getAnswerKey() returns a single dimensional array and getStudentAnswers() returns a two dimensional array. Note: getStudentAnswers() should take a single parameter specifying the number of questions (you can determine the value by looking at the array returned by getAnswerKey() ) – use this value to check that the user entered the correct number of answers for each student. Use your gradeExams() method to grade the user-supplied info.

Expert Answer

import java.util.*;

public class GradeSystem
{

public static void gradeExams(int k[], int answers[][])
{
for(int i=0;i<answers.length;i++)
{
System.out.println(“Grades of Student “+(i+1));
gradeExam(k,answers[i]);
}
}
public static void gradeExam(int k[], int answers[])
{
int r=0,w=0;
for(int i=0;i<answers.length;i++)
{
if(answers[i]==k[i]) r++;
else w++;
}

System.out.println(“Total right answers: “+r+”nTotal Wrong answers: “+w);
System.out.println(“Percentage: “+(((float)r/(answers.length))*100));
}
public static int[] getAnswerKey()
{
int n=0;

Scanner s= new Scanner(System.in);
System.out.println(“Enter total no. of questions “);
n=s.nextInt();

int[] ans = new int[n];

System.out.println(“Enter “+n+” answers: “);
for(int i=0;i<n;i++)
{
ans[i]=s.nextInt();
}

return ans;

}

public static int[][] getStudentAnswers(int k)
{
Scanner s= new Scanner(System.in);
System.out.println(“Enter total no. of students “);
int n=s.nextInt();

int [][] answers = new int[n][k];
for(int i=0;i<n;i++)
{
System.out.println(“Please Enter answers of student “+(i+1));
for(int j=0;j<k;j++)
{
answers[i][j]=s.nextInt();
}
}

return answers;

}
public static void main(String[] args) {

int[] key;
int[][] answers;

key=getAnswerKey();
answers=getStudentAnswers(key.length);

gradeExams(key, answers);

}
}

Still stressed from student homework?
Get quality assistance from academic writers!