Question: Create a java application that grades a multiple choice quiz. The application will do the following: Prompt the user to enter the number of questions

Create a java application that grades a multiple choice quiz.

The application will do the following:

Prompt the user to enter the number of questions for the quiz, then prompt the user to enter the answer key for each question. Use an array.

Prompt:

Create an array of Students that will contain the students name and grade on the quiz.

From a file, read each students name and quiz answers.

By comparing the entered answers to the answer key, the program can determine if the answer is correct or incorrect. Count the correct answers and store the final score for each student.

Display a report of students' grades, the highest grade, the lowest grade, and the average score for the class.

This is the error message:

Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 6

at StudentScore.main(StudentScore.java:46)

PROGRAM THAT ISN'T RUNNING

import java.io.*;

import java.util.*;

public class StudentScore

{

public static void main(String[] args) throws ArrayIndexOutOfBoundsException

{

int numques=10;

Scanner scan = new Scanner(System.in);

System.out.print("Please enter the number of questions?");

numques = scan.nextInt();

String[] key = new String[numques];

for(int i=0;i

{

int j=i+1;

System.out.print("What is the key for question number "+j+"?");

key[i] = scan.next();

}

int numstu=10;

System.out.print("Please enter the number of students?");

numstu = scan.nextInt();

int[] sans = new int[numstu];

String[] sname = new String[numstu];

System.out.print("Please enter the complete file path for students answers:"); // example C:\\Users\\... etc

String file = scan.next();

try (BufferedReader br = new BufferedReader(new FileReader(file))) {

String line;

String[] a=new String[30];

int kl=0;

while ((line = br.readLine()) != null) {

// process the line.

a = line.split(" ");

sname[kl]=a[0];

sans[kl]=0;

for(int ik=0;ik

{

if(key[ik].equals(a[ik+1]))

{

sans[kl]++;

}

}

kl++;

}

}

catch (FileNotFoundException e)

{

// TODO Auto-generated catch block

e.printStackTrace();

}

catch (IOException e)

{

// TODO Auto-generated catch block

e.printStackTrace();

}

System.out.println("Name and score for each student:");

System.out.println("=================================");

int max=0,min=0;

double sum=0;

for(int i=0;i

{

if(sans[i]>sans[max])max=i;

if(sans[i]

sum+=sans[i];

System.out.print(sname[i]+' ');

System.out.println(sans[i]);

}

System.out.print("The maximum score is ");

System.out.print(sans[max]);

System.out.println(" for student "+sname[max]);

System.out.print("The minimum score is ");

System.out.print(sans[min]);

System.out.println(" for student "+sname[min]);

System.out.print("The average score is ");

System.out.println(sum/numstu);

}

}

this is the data file

student1 b d d b d

student2 a d d b d

student3 b b a d d

student4 b b a b a

student5 b a a d b

student6 d d d b a

student7 d a a d b

student8 d b d b d

student9 b d d a b

student10 d b d d b

student11 d b d a a

student12 d d b a d

student13 d b d a b

student14 b d b b d

student15 d b b d d

student16 d b b a b

student17 d d d b d

student18 b a d b d

student19 d b a b d

student20 d d b b d

student21 d d a b d

student22 d d d d b

student23 d d a d d

student24 d d d d b

student25 a d a a d

student26 a d b b a

student27 d d b b a

student28 d a d d d

student29 b d d d d

student30 d b d d b

student31 d a d a d

student32 b d a d a

student33 a d d a b

student34 b a d b b

student35 a d d d a

student36 a d d b d

student37 d a d b b

student38 b d d b d

student39 b d d b a

student40 d d a d a

student41 d d b b d

student42 d d d a d

student43 d a a d b

student44 a d b d d

student45 a b b b d

student46 b d d d d

student47 a d d d d

student48 a d d a d

student49 b a d d d

student50 b d d d b

student51 d a b d d

student52 d d a d a

student53 d d d d d

student54 a a a d d

student55 d d d d a

student56 d d d a d

student57 b d d a a

student58 d d d a b

student59 d d b d b

student60 d a b a d

student61 d a b b b

student62 b d d b b

student63 b d b b d

student64 b b b a a

student65 b b b d d

student66 a b d b b

student67 a d d d d

student68 d d d b a

student69 b a b b d

student70 d a b d a

student71 d d b b d

student72 a a d d d

student73 b d b d d

student74 d d a b b

student75 d b d b a

student76 d b a d d

student77 d d d d b

student78 d a a a b

student79 d d d a b

student80 d b d d d

student81 a d d d b

student82 b b d d b

student83 d d d b b

student84 d d d a d

student85 a d d a a

student86 a b d d d

student87 d d d a b

student88 d b a a b

student89 d d a a d

student90 d d a b b

student91 d d d b b

student92 d d a a b

student93 d b d a d

student94 d b d d d

student95 d d d d d

student96 a b d d d

student97 d d d d a

student98 d d b d b

student99 d d d d d

student100 a a a d a

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!