Related questions
Concept explainers
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
Trending nowThis is a popular solution!
Step by stepSolved in 5 steps
- Can you please make this in Java?arrow_forwardfor beginning java, here's my assignment " Write a program that ask the user to enter a list of positive scores until the user enters a negative score to terminate the input. You need to store these scores in an array. You can assume the maximum number of scores the user may enter is 50. However, you need to keep track of the actual number of scores entered. Write 2 methods: 1. calculateAverage(): this method takes the list of scores and return the average score. 2. countPerfectScores(): this method takes the list of scores and return the number of perfect scores (100). The main program reads the input and calls these methods and print the results. Please make sure you write a comment line to document what your method does." Here is my code, " import java.util.Scanner;class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); // Start array for scores int[] scores = new int[50]; int size = 0; // Have user enter scores until...arrow_forwardPlease assist with the attached question using Java language. Thanks.arrow_forward
- 6) Write a program that declares a 10-element integer array. Initialise the arrays with the values: 10, 20, 30, 40, 50, 60, 70, 80, 90, 100 using a for loop. Then output the array values.arrow_forwardJAVA Write a program that plays a number-guessing game to guess a secret number randomly generated within the range 1 and 10. The user will get as many numbers of tries as he/she needs to guess the number. Tell the users if their guess is right or wrong and if their guess is wrong let them try to guess the number again. You have solved a similar problem in a previous lab using a while loop. You must generate the secret number using the Java Random class. When the user guesses a number he/she will have to take an input of his guessed number from the keyboard. The user will have to take as many inputs as needed to guess the correct secret-number. That means the code will keep looping as long as the guess is different from the secret number. You also need to count the number of tries and report the count at the end. Use a do-while loop to prompt the user to guess again if the guess is wrong. Make sure that it doesn't mess up the output if you guess the secret number on the first try....arrow_forwardIn Java: Forms often allow a user to enter an integer. Write a program that takes in a string representing an integer as input, and outputs yes if every character is a digit 0-9. Ex: If the input is: 1995 the output is: yes Ex: If the input is: 42,000 or 1995! the output is: no Hint: Use a loop and the Character.isDigit() function.arrow_forward
- Text book imageDatabase System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationText book imageStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONText book imageDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- Text book imageC How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONText book imageDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningText book imageProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education