Question: How would I change the provided java file to do the following: - First, at the top of your program, ask the user how many

How would I change the provided java file to do the following:

- First, at the top of your program, ask the user how many students there are in the class - Loop through and input each students answers, grade the quiz, and display the result for each student - After all students have been processed, display the values of the high and low scores and the average quiz score as a percentage (1 decimal)

import java.util.Scanner; import java.text.DecimalFormat;

public class QuizGrade{ public static void main(String[] args){ Scanner x = new Scanner(System.in); DecimalFormat df = new DecimalFormat("#0.00"); char [][] answerKey = { {'B', 'D', 'A', 'A'}, {'C', 'A', 'B', 'A'}, {'C', 'D', 'B', 'A'} }; final int NUMQUESTIONS = 12; int correct = 0; String name; char [] answer = new char[NUMQUESTIONS]; int row; int column; char y; double score;

System.out.print("Please enter your name: "); name = x.nextLine();

for(int i = 0; i < NUMQUESTIONS; i++){ System.out.println("Enter quiz answers: "); y = x.nextLine().charAt(0); answer[i] = y; } for(row = 0; row<3; row++){ for(column = 0; column<4; column++){ if(answer[row*4+column]==answerKey[row][column]){ correct++; } } } System.out.println(" "); System.out.println(name); System.out.println(correct + " out of "+ NUMQUESTIONS); score = ((correct)/(double)(NUMQUESTIONS)*100); System.out.printf("%.1f%%",score);

} }

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!