assignment in upload
Quiz.java
Quiz.Java
Public class Quiz {
Public static void main(String[] args)
MultipleChoiceQuestion question1= new MultipleChoiceQuestion(
”1. Which two NFL Teams will be playing in the super bowl 2022?”,
”Rams and Bengals”,
“Packers and Commanders”,
“Vikings and Eagles”,
“Raiders and Saints”,
“Dolphins and Bears”,
“a”);
MultipleChoiceQuestion question2= new MultipleChoiceQuestion(
“2. Which continent is the United States of America Located?”,
”Asia”,
”Antarctica”,
”Oceania”,
”Europe”,
”Africa”,
”North America and South America”,
”d”);
MultipleChoiceQuestion3 question3=new MultipleChoiceQuestion(
”3. What is Lebron James Career?”,
“Diplomat”,
“Soccer Player”,
“Teacher”,
“Basketball Player,”
“Soccer Player”,
”d”);
MultipleChoiceQuestion question4 = new MultipleChoiceQuestion(
”4. Who is the owner of Tesla?”,
“Barack Obama”,
”Elon Musk”,
”Kim kardashian”,
”Stephen curry”
”Bill Gates”,
”b”);
MultipleChoiceQuestion question5=new MultipleChoiceQuestion(
“5. Who featured on the song Despacito?”,
”Daddy Yankee”,
“Chris Brown”,
“Justin Timberlake”,
“Bad Bunny”,
“Jay z”,
”a”);
question1.check();
question2.check();
question3.check();
question4.check();
question5.check();
MultipleChoiceQuestion.showResults( );
}
}
MultipleChoiceQuestion.java
import javax.swing.JOptionPane;
class MultipleChoiceQuestion { static int nQuestions
String questions; String correctAnswer;
MultipleChoiceQuestions( String a, String b, String c , String d, String e, String answer) { question +=”A, Rams and bengalsn”; question +=”B, North America and South American”; question +=”C, Basketballn”; question +=”D, Elon muskn”; question +=”E, Daddy yankeen”;
Answer = answer.toUpperCase( );
}
String ask() { String answer; while(true) {
answer= JOptionPane.showInputDialog(question); answer= answer.toUpperCase(); if(answer.equals(”A”) || answer.equals(”B”) || answer.equals(”C”) || answer.equals(”D”)|| answer.equals(”E”)) { return answer; }else{ JOptionPane.showMessageDialog(null,”Invalid! Please enter A,B,C,D,or E.”); }
}
}
String answer=ask(); if(answer.equals(correctAnswer)) { JOptionPane.showMessageDialog(null,”Correct!”); nCorrect++; } else JOptionPane.showMessageDialog(null,”Incorrect. The correct answer is “+correctAnswer+”.”); nQuestions++; } static void showResults() { JOptionPane.showMessageDialog(null,nCorrect+” correct out of ”+nQuestions+” questions.”);
Delivering a high-quality product at a reasonable price is not enough anymore.
That’s why we have developed 5 beneficial guarantees that will make your experience with our service enjoyable, easy, and safe.
You have to be 100% sure of the quality of your product to give a money-back guarantee. This describes us perfectly. Make sure that this guarantee is totally transparent.
Read moreEach paper is composed from scratch, according to your instructions. It is then checked by our plagiarism-detection software. There is no gap where plagiarism could squeeze in.
Read moreThanks to our free revisions, there is no way for you to be unsatisfied. We will work on your paper until you are completely happy with the result.
Read moreYour email is safe, as we store it according to international data protection rules. Your bank details are secure, as we use only reliable payment systems.
Read moreBy sending us your money, you buy the service we provide. Check out our terms and conditions if you prefer business talks to be laid out in official language.
Read more