CODE IN JAVA design a program that grades arithmetic quizzes as follows: (Use the below startup code for Quizzes.java and provide code as indicated by the comments) 1. Ask the user how many questions are in the quiz. 2. 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 in the quiz, and each answer should be an integer. They can 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". 3. 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. need this in a separate for loop from the loop used to load the array. 4. When the user has entered all of the answers to be graded, print the number correct and the percent correct. 5. 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)." //****************************************************************** // Quizzes.java // Grades multiple choice quizzes. //****************************************************************** import java.util.Scanner; import java.text.NumberFormat; public class Quizzes { //---------------------------------------------- // Read in the number of questions followed by // the key, then read in each student's answers // and calculate the number and percent correct. //---------------------------------------------- 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 (); System.out.print ("Enter the number of questions on the quiz: "); numQuestions = scan.nextInt(); //CREATE THE ARRAY FOR THE KEY System.out.print ("Enter the answer key: "); //LOAD THE ARRAY FOR THE ANSWER KEY WITH INPUT FROM THE USER //OUTER LOOP TO ALLOW THE USER TO ENTER GRADES // FOR ANY NUMBER OF QUIZZES System.out.print("Enter the student answers: "); //INNER LOOP TO GET ANSWERS FROM THE USER AND COUNT THE NUMBER OF // CORRECT ANSWERS //DISPLAY THE NUMBER OF CORRECT ANSWERS AND PERCENT //ASK USER IF THEY WISH TO GRADE ANOTHER QUIZ

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

CODE IN JAVA

design a program that grades arithmetic quizzes as follows: (Use the below startup code for Quizzes.java and provide code as indicated by the comments)

 

1. Ask the user how many questions are in the quiz.

 

2. 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 in the quiz, and each answer should be an integer. They can 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".

 

3. 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.  need this in a separate for loop from the loop used to load the array.

 

4. When the user has entered all of the answers to be graded, print the number correct and the percent correct.

 

5. 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)."

 

//******************************************************************
//  Quizzes.java
//  Grades multiple choice quizzes.
//******************************************************************

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

public class Quizzes
{
   //----------------------------------------------
    // Read in the number of questions followed by 
    // the key, then read in each student's answers
    // and calculate the number and percent correct.
    //----------------------------------------------
 

  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 ();
   System.out.print ("Enter the number of questions on the quiz: ");
   numQuestions = scan.nextInt();

 

   //CREATE THE ARRAY FOR THE KEY

 

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


   //LOAD THE ARRAY FOR THE ANSWER KEY WITH INPUT FROM THE USER

 

 

   //OUTER LOOP TO ALLOW THE USER TO ENTER GRADES 

   // FOR ANY NUMBER OF QUIZZES


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

 

    //INNER LOOP TO GET ANSWERS FROM THE USER AND COUNT THE NUMBER OF

    // CORRECT ANSWERS

 

    //DISPLAY THE NUMBER OF CORRECT ANSWERS AND PERCENT

 

    //ASK USER IF THEY WISH TO GRADE ANOTHER QUIZ

 

Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Array
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education