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

Write a program that grades arithmetic quizzes as follows: (Use the below startu

ID: 3696788 • Letter: W

Question

Write a program that grades arithmetic quizzes as follows: (Use the below startup code foe Quizzes.java and provide code as indicated) Ask the user bow many questions are in the quiz. Use a for loop to load the array. Ask the user to enter the key (that is, the correct answers). There should be one answer for each question m the quiz, and each answer should be an integer. They car be entered on a single line, e g., 34, 7, 13, 100, 8 might be the key for a 5-question quiz. You will need to store the key in an array called "key". Ask the user to enter the student's answers for the quiz to be graded. There needs to be one answer for each question. Note that each answer can simply be compared to the key as it is entered. If the answer is correct, add 1 to a correct answer counter. Do this in a separate for loop from the loop used to load the array. When the user has entered all of the answers to be graded, print the number correct and the percent correct. When this works, nest your for loop and output statements in a do....while loop so that the user can grade any number of quizzes with a single key. After the results have been printed for each quiz, ask "Grade another quiz? (y/n)."

Explanation / Answer

import java.text.NumberFormat;
import java.util.*;
public class Quizzes {
   public static void main(String[] args)
   {
       Scanner scan = new Scanner(System.in);
       int numQuestions;
       int numCorrect;
       String anotherQuiz;
       int answer;
       NumberFormat percent = NumberFormat.getPercentInstance();
       System.out.println("Quiz Grading");
       System.out.println("");
       System.out.print("Enter the number of questions in the quiz:");
       numQuestions = scan.nextInt();
       int[] key = new int[numQuestions];
       System.out.print("Enter the answer key:");
       for(int i=0;i<numQuestions;i++)key[i] = scan.nextInt();
      
       do
       {
           numCorrect=0;
           System.out.print("Enter the answer given by the student:");
           for(int i=0;i<numQuestions;i++)
           {
               answer = scan.nextInt();
               if(answer==key[i])numCorrect++;
           }
           System.out.println("The number of correct answers is"+numCorrect);
           System.out.println("The percentage of correct answers is "+percent.format(numCorrect*1.0/numQuestions));
           System.out.print("Do you want to grade another quiz?(Y/N):");
           anotherQuiz = scan.next();
       }while(anotherQuiz.equals("Y"));
   }
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote