Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions