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

Write an application that contains 10 multiple-choice quiz questions related to

ID: 3765917 • Letter: W

Question

Write an application that contains 10 multiple-choice quiz questions related to your favorite hobby. Each question should contain three answer choices, named A, B and C. Another array holds the correct answer to each question --- A, B or C. Display each question.

Write a method to make sure that user response is either A or B or C only. If not, keep prompting the user until a valid response is entered. If the user response is correct, display the message “Correct!”; if not, display the message “The correct answer is “ and the letter of the correct answer.

After the user answers all the questions, compute the number of correct answers and the percentage.

Use a void method to display the relevant outputs. Submit the final program.

You can make up whatever question you like!

Explanation / Answer

import java.util.*;

class quiz_check
{
   public static void main(String args[])
   {
       String quest[]={"Computer is

Machine?","Man is Reptile?","Monkey is Mamal?","Capital

of US is New Delhi","Capital of India is

Mumbai","Education is important in life","Computer can

Think", "Smoking is injurious to health","Teachers must be

respected","We must set Goal of our Life"} ;
       int i,j,c=0;

       char act_ans[]=

{'A','B','C','A','B','C','A','B','C','A'};
       char ans;      
       Scanner scan = new Scanner

(System.in);
       for(i=0;i<10;i++)
       {
           System.out.println(quest[i]);
           System.out.println("A.

True");  
           System.out.println("B.

False");
           System.out.println("C. Can't

Say");

           ans=scan.nextLine().charAt

(0);
           if(ans==act_ans[i])
           {
              

System.out.println("Correct!");
               c++;
           }
           else
           {
              

System.out.println("The correct answer is "+act_ans[i]);
           }
       }
       System.out.println("Number of correct

answers are "+c);
   }
}
  

      

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