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

Project 5 Create a java application that grades a multiple choice quiz. The appl

ID: 3807417 • Letter: P

Question

Project 5

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.

Create an array of Students that will contain the student’s name and grade on the quiz.

From a file, read each student’s 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.

Explanation / Answer

import java.util.Scanner;
import java.text.NumberFormat;

public class Quizzes
{
public static void main(String[] args)
{
int numQuestions;
int numCorrect;
String anotherQuiz;
int answer;
NumberFormat percent = NumberFormat.getPercentInstance();

Scanner scan = new Scanner(System.in);

System.out.println("Quiz Grading");
System.out.println();

do
{
System.out.print("Enter the number of questions on the quiz: ");
numQuestions = scan.nextInt();

int[] key = new int[numQuestions];

System.out.print("Enter the answer key: ");

for (int i = 0; i < numQuestions; i++)
{
System.out
.print("Enter the key for Question " + (i + 1) + ": ");
key[i] = scan.nextInt();
}

System.out.print("Enter the student answers: ");

numCorrect = 0;
for (int i = 0; i < numQuestions; i++)
{
System.out.print("Enter the Answer for Question " + (i + 1)
+ ": ");
answer = scan.nextInt();
if (answer == key[i])
{
numCorrect++;
}

}

System.out.println("Number of Correct Answers :" + numCorrect);
System.out.printf("Percent correct :%.2f ",
((float) numCorrect / (float) numQuestions) * 100.0);

System.out.print("Grade another quiz? (y/n):");
anotherQuiz = scan.next();
if (anotherQuiz.equals("n"))
break;
}
while (true);
}

}

import java.util.Scanner;

public class ReverseArray
{
public static void main(String[] args)
{
int numElements;
Scanner scan = new Scanner(System.in);

System.out.print("Enter the number of elements in the array: ");
numElements = scan.nextInt();

int[] a = new int[numElements];

System.out.println("Enter the array elements (integers)...");
for (int i = 0; i < numElements; i++)
{
System.out.print("Enter element " + (i + 1) + ": ");
a[i] = scan.nextInt();
}

System.out.println();
System.out.println("The array elements before reversing:");
for (int i = 0; i < numElements; i++)
System.out.print(a[i] + " ");
System.out.println();

for (int i = 0; i < numElements / 2; i++)
{
int temp = a[i];
a[i] = a[numElements - 1 - i];
a[numElements - 1 - i] = temp;
}

System.out.println(" The array after reversing: ");
for (int i = 0; i < numElements; i++)
System.out.print(a[i] + " ");
System.out.println();
}
}