Database System Concepts
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
Bartleby Related Questions Icon

Related questions

bartleby

Concept explainers

Question
100%

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

Ask the user how 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 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".

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

//******************************************************************
// 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 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: ");

//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
Check Mark
Knowledge Booster
Background pattern image
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
    Recommended textbooks for you
    Text book image
    Database System Concepts
    Computer Science
    ISBN:9780078022159
    Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
    Publisher:McGraw-Hill Education
    Text book image
    Starting Out with Python (4th Edition)
    Computer Science
    ISBN:9780134444321
    Author:Tony Gaddis
    Publisher:PEARSON
    Text book image
    Digital Fundamentals (11th Edition)
    Computer Science
    ISBN:9780132737968
    Author:Thomas L. Floyd
    Publisher:PEARSON
    Text book image
    C How to Program (8th Edition)
    Computer Science
    ISBN:9780133976892
    Author:Paul J. Deitel, Harvey Deitel
    Publisher:PEARSON
    Text book image
    Database Systems: Design, Implementation, & Manag...
    Computer Science
    ISBN:9781337627900
    Author:Carlos Coronel, Steven Morris
    Publisher:Cengage Learning
    Text book image
    Programmable Logic Controllers
    Computer Science
    ISBN:9780073373843
    Author:Frank D. Petruzella
    Publisher:McGraw-Hill Education