Question: My prompt is to: Create a java application that grades a multiple choice quiz. The application will do the following: Prompt the user to enter
My prompt is to:
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 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 what I already have done:
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(); } }
My question is, using my current program how do I:
1.) Ask how many students are in the class and input their names
2.) For the program to output the quiz grade for that student
3.) And display it in a table from highest to lowest grade and the average of the class
Any help would be greatly appreciated! Thanks you!
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
