assignment in upload , Modify the previous program below, Upload one document to

by | May 14, 2022 | Computer Science | 0 comments

assignment in upload , Modify the previous program below, Upload one document to the submission area that includes the following:
QuestionDialog.java
Question.java
TrueFalseQuestion.java
MultipleChoiceQuestion.java
A screenshot showing a dialog box asking a true/false question
A screenshot showing a dialog box asking a multiple-choice question
Import javax.swing.JOptionPane;
public class MultipleChoiceQuestion extends Question{
MultipleChoiceQuestion (String query,String a, String b, String c,String d, String e, String answer){
question = query+”n”;
question += “A. “+a+”n”;
question += “B. “+b+”n”;
question += “C. “+c+”n”;
question += “D. “+d+”n”;
question += “E. “+e+”n”;
correctAnswer= answer.toUpperCase();
}
@Override
String ask() {
while (true) {
String answer = JOptionPane.showInputDialog(question);
answer = answer.toUpperCase();
boolean valid = (answer.equals(“A”) || answer.equals(“B”) ||answer.equals(“C”) || answer.equals(“D”) || answer.equals(“E”));
if (valid)
return answer;
else {
JOptionPane.showMessageDialog(null,”Invalid answer. Please enter A, B, C, D, or E.”);
}
}
}
}
import javax.swing.JOptionPane;
public abstract class Question {
static int nQuestions = 0;
static int nCorrect = 0;
String question;
String correctAnswer;
abstract String ask();
void check() {
nQuestions++;
String answer = ask();
if(answer.equals(correctAnswer)) {
JOptionPane.showMessageDialog(null,”Correct”);
nCorrect++;
}
else {
JOptionPane.showMessageDialog(null,”Incorrect. The correct answer is “+correctAnswer+”.”);}
}
static void showResults() {
JOptionPane.showMessageDialog(null,nCorrect+” correct out of”+nQuestions+”questions”);
}
}
public class Quiz {
public static void main(String[] args) {
Question question = new TrueFalseQuestion(“: Coding is fun!”,”y”);
question.check();
question = new TrueFalseQuestion(“: Programming is more fun than coding!”,”y”);
question.check();
question = new TrueFalseQuestion(“: Africa is a developing continent.”,”t”);
question.check();
question = new TrueFalseQuestion(“: Russia is invading Ukraine.”,”t”);
question.check();
question = new TrueFalseQuestion(“: Russia will suffer after the UN sactions.”,”t”);
question.check();
question = new MultipleChoiceQuestion(“How many countries are Africa?”,
“34.”,
“20.”,
“45.”,
“54.”,
“33.”,
“d”);
question.check();
MultipleChoiceQuestion question1 = new MultipleChoiceQuestion(“How many countries are there in the whole world?”,
“300.”,
“250”,
“195”,
“150”,
“100”,
“c”);
question1.check();
MultipleChoiceQuestion question2 = new MultipleChoiceQuestion(“How many days does it take for the Earth to orbit the Sun?”,
“365.”,
“185.”,
“225.”,
“196.”,
“128.”,
“a”);
question2.check();
MultipleChoiceQuestion question3 = new MultipleChoiceQuestion(“How many days in Feb in a leap year?”,
“28.”,
“29.”,
“30.”,
“31.”,
“27.”,
“b”);
question3.check();
MultipleChoiceQuestion question4 = new MultipleChoiceQuestion(“How many states does US have?”,
“54.”,
“56.”,
“53.”,
“50.”,
“51.”,
“d”);
question4.check();
}
}
import javax.swing.JOptionPane;
public class TrueFalseQuestion extends Question{
TrueFalseQuestion(String question, String answer){
this.question = “TRUE or FALSE” +question;
answer =answer.toUpperCase();
if(answer.equals(“T”)||answer.equals(“True”)||answer.equals(“Y”)||answer.equals(“YES”))
correctAnswer = “TRUE”;
if(answer.equals(“F”)||answer.equals(“FALSE”)||answer.equals(“N”)||answer.equals(“NO”))
correctAnswer = “FALSE”;
}
@Override
String ask() {
while(true) {
String answer =JOptionPane.showInputDialog(question);
answer =answer.toUpperCase();
if (answer.equals(“T”)|| answer.equals(“Y”) || answer.equals(“YES”))
answer = “TRUE”;
if (answer.equals(“F”)|| answer.equals(“N”) || answer.equals(“NO”))
answer = “FALSE”;
boolean valid = (answer.equals(“FALSE”)|| answer.equals(“TRUE”));
if(valid)
return answer;
else {
JOptionPane.showMessageDialog(null,”Invalid answer. Please enter TRUE or FALSE.”);
}
}
}
}

Save your time - order a paper! Get your paper written from scratch within the tight deadline. Our service is a reliable solution to all your troubles. Place an order on any task and we will take care of it. You won’t have to worry about the quality and deadlines

Save your time - order a paper!

Get your paper written from scratch within the tight deadline. Our service is a reliable solution to all your troubles. Place an order on any task and we will take care of it. You won’t have to worry about the quality and deadlines

Ordering Process

TESTIMONIALS

What People Are Saying

I had casually placed an order on Lesson-edu.info for a short essay and wanted to see if their claim of timely delivery of tasks was true or not. The assignment was not delivered on time, but the quality of the essay was also remarkable.

Adeline West

“Being associated with experts minds for 1 year, i am extremely happy and fully satisfied with your high class assistance and quality writing services! Cheers!”

Rachel

“Thanks guys! You have great writer who helped me in my last assignment! I got excellent grade in my last assignment and i will recommend you!”

Theresa Reeves

“It was awesome experience to work with professional writers of experts ! This really helps to score high in university homework!”

Ada Leonard

We're Here To Help!

{b93f8ed3eaa33b78386a66dd2d970b220266e0f4bf12ec238f72e42ef3699669}{b93f8ed3eaa33b78386a66dd2d970b220266e0f4bf12ec238f72e42ef3699669}109{b93f8ed3eaa33b78386a66dd2d970b220266e0f4bf12ec238f72e42ef3699669}{b93f8ed3eaa33b78386a66dd2d970b220266e0f4bf12ec238f72e42ef3699669}

Email

support@exquisiteessaywritings.com

{b93f8ed3eaa33b78386a66dd2d970b220266e0f4bf12ec238f72e42ef3699669}{b93f8ed3eaa33b78386a66dd2d970b220266e0f4bf12ec238f72e42ef3699669}264{b93f8ed3eaa33b78386a66dd2d970b220266e0f4bf12ec238f72e42ef3699669}{b93f8ed3eaa33b78386a66dd2d970b220266e0f4bf12ec238f72e42ef3699669}

Call Us

+1 (629) 237-5579