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

Write an application that creates a quiz, which contains at least 10 questions a

ID: 3691917 • Letter: W

Question

Write an application that creates a quiz, which contains at least 10 questions about java question (Ex: who creat java ,what year java creat etc.). Each question should be a multiple choice question with at least four options. When a user answers a question correctly, display a congratulatory message. If a user responds to a question incorrectly, display an appropriate message as well as a correct answer. At the end of the quiz display the number of correct and incorrect answers and the percentage of correct answers. Save the file as Quiz.java. Also, I need to accomplish this with arrays.

Explanation / Answer

Quiz.java

import java.util.Scanner;
public class Quiz

{

   public static void main(String [] args)
   {
          ///Declaring Variables
       int correctAnswer = 0 ;
       int incorrectAnswer = 0 ;
       int quizChoice = 0;
        final int option_one = 1;
       final int option_two = 2;
       final int option_three = 3;
       final int option_four = 4;
           ///Creating scanner, and setting up questions
       Scanner input = new Scanner(System.in);
       System.out.println
           ("Who was the original drummer for the Ramones?");
        System.out.print("Enter " + option_one + " for Joey Ramone " +
         option_two + " for Dee Dee Ramone " + option_three + " for Tommy Ramone " +
         option_four + " for Marky Ramone ");
        quizChoice = input.nextInt();
        if(quizChoice != 1)
        {
           /// All incorrect and correct answers for each question can incremented by 1
            incorrectAnswer = incorrectAnswer + 1;
            System.out.println("You are wrong! The answer is " + option_one + " Joey Ramone ");

        }
        else
           {
             correctAnswer = correctAnswer + 1;
             System.out.println(" You are Correct! the answer is " + option_one + " Joey Ramone ");
           }
        System.out.println
           (" Who is the elventh Doctor Who?");
        System.out.print("Enter " + option_one + " for Christopher Eccleston " +
         option_two + " for Steven Patrick Morrissey " + option_three + " for Joel Hodgson " +
         option_four + " for Matt Smith ");
        quizChoice = input.nextInt();

        if(quizChoice != 4)
        {
            incorrectAnswer = incorrectAnswer + 1;
            System.out.println(" You are wrong! The answer is " + option_four + " Matt Smith ");

        }
        else
           {
               correctAnswer = correctAnswer + 1;
             System.out.println(" You are Correct! the answer is " + option_four + " Matt Smith! ");
           }
         System.out.println
           (" Who is the unofficial seventh member of Monty Python? ");
        System.out.print("Enter " + option_one + " for Dylan Moran " +
         option_two + " for Carol Cleveland " + option_three + " for Connie Booth " +
         option_four + " for Terry Gilliam ");
        quizChoice = input.nextInt();
        if(quizChoice != 2)
        {
            incorrectAnswer = incorrectAnswer + 1;
            System.out.println("You are wrong! The answer is " + option_two + " Carol Cleveland ");
        }
        else
           {
             correctAnswer = correctAnswer + 1;
             System.out.println(" You are Correct! the answer is " + option_two + " Carol Cleveland! ");
           }
         System.out.println
           (" Who wrote the comic series The Sandman ");
        System.out.print("Enter " + option_one + " for Neil Gaiman " +
         option_two + " for Dave McKean " + option_three + " for Alan Moore " +
         option_four + " for Warren Ellis ");
         quizChoice = input.nextInt();
        if(quizChoice != 1)
        {
            incorrectAnswer = incorrectAnswer + 1;
            System.out.println("You are wrong! The answer is " + option_one + " Neil Gaiman ");
        }
        else
           {
             correctAnswer = correctAnswer + 1;
             System.out.println(" You are Correct! the answer is " + option_one + " Neil Gaiman! ");
           }
           System.out.println
           (" Who killed Laura Palmer?");
        System.out.print("Enter " + option_one + " Bob/Leland Palmer " +
         option_two + " Leland Palmer " + option_three + " Harry S. Truman " +
         option_four + " Leo Johnson ");
        quizChoice = input.nextInt();

        if(quizChoice != 1)
        {
            incorrectAnswer = incorrectAnswer + 1;
            System.out.println("You are wrong! The answer is " + option_one + " Bob/Leland Palmer ");

        }
        else
           {
             correctAnswer = correctAnswer + 1;
             System.out.println(" You are Correct! the answer is " + option_one + " Bob/Leland Palmer ");
             }
              ///Prints out the correct answers, the incorrect answers, and the overall score.
           System.out.println(" You answered " + correctAnswer + " correct ");
           System.out.println(" You answered " + incorrectAnswer + " incorrect ");
           System.out.println(" Your score for this test is " +(correctAnswer * 20) + "%");

    }
}


sample output

Who was the original drummer for the Ramones?                                                                                                               
Enter                                                                                                                                                       
1 for Joey Ramone                                                                                                                                          
2 for Dee Dee Ramone                                                                                                                                       
3 for Tommy Ramone                                                                                                                                         
4 for Marky Ramone 1                                                                                                                                       
You are Correct! the answer is 1 Joey Ramone                                                                                                               
                                                                                                                                                            
Who is the elventh Doctor Who?                                                                                                                              
Enter                                                                                                                                                       
1 for Christopher Eccleston                                                                                                                                
2 for Steven Patrick Morrissey                                                                                                                             
3 for Joel Hodgson                                                                                                                                         
4 for Matt Smith 2                                                                                                                                         
You are wrong! The answer is 4 Matt Smith                                                                                                                  
Who is the unofficial seventh member of Monty Python?                                                                                                       
Enter                                                                                                                                                       
1 for Dylan Moran                                                                                                                                          
2 for Carol Cleveland                                                                                                                                      
3 for Connie Booth                                                                                                                                         
4 for Terry Gilliam 3                                                                                                                                      
You are wrong! The answer is 2 Carol Cleveland                                                                                                              
                                                                                                                                                            
Who wrote the comic series The Sandman                                                                                                                      
Enter                                                                                                                                                       
1 for Neil Gaiman                                                                                                                                          
2 for Dave McKean                                                                                                                                          
3 for Alan Moore                                                                                                                                           
4 for Warren Ellis 4                                                                                                                                       
You are wrong! The answer is 1 Neil Gaiman                                                                                                                  
                                                                                                                                                            
Who killed Laura Palmer?                                                                                                                                    
Enter                                                                                                                                                       
1 Bob/Leland Palmer                                                                                                                                       
2 Leland Palmer                                                                                                                                            
3 Harry S. Truman                                                                                                                                          
4 Leo Johnson 1                                                                                                                                            
You are Correct! the answer is 1 Bob/Leland Palmer                                                                                                         
                                                                                                                                                            
You answered 2 correct                                                                                                                                     
                                                                                                                                                            
You answered 3 incorrect                                                                                                                                   
                                                                                                                                                            
Your score for this test is 40%                                                                                                                             

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