Quiz.java because I am showing bugs and errors on my coding from the s

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Please help me with the section in Quiz.java because I am showing bugs and errors on my coding from the screen shots I am including with this message.  I have no bugs for MultipleChoiceQuestion.java.  I only need help with Quiz.java.

 

MultipleChoiceQuestion.java

import javax.swing.JOptionPane;
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
public class MultipleChoiceQuestion {
static int nQuestions = 0;
static int nCorrect = 0;
String question;
String correctAnswer;
MultipleChoiceQuestion(String query, String a, String b, String c, String d, String e, String
answwer) {
question = query+ "\n";
question +="A."+a+"\n";
question +="B."+b+"\n";
question +="C."+c+"\n";
question +="D."+d+"\n";
question +="E."+e+"\n";

correctAnswer = correctAnswer.toUpperCase();
}
public 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;
JOptionPane.showMessageDialog(null,"Invalid answer. Please answer A,B,C,D,or "
+ "E.");
}
}

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");
}
}

 

Quiz.java

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
public class Quiz {

public static void main(String[] args) {
MultipleChoiceQuestion question = new MultipleChoiceQuestion("What is a quiz?",
"a test of knowledge, especially a brief informal test given to students",
"42",
"a duck",
"to get to the other side",
"To be or not to be, that is the question.",
"a");
question.check();
question.showResults();
MultipleChoiceQuestion question1 = new MultipleChoiceQuestion("When is a quiz?",
"a long, long ago",
"right now",
"the best of times",
"the worst of times",
"nevermore","b");
question1.check();
question1.showResults();
MultipleChoiceQuestion question2 = new MultipleChoiceQuestion("Where is a quiz?",
"a galaxy far, far away",
"under the sea",
"right here",
"there and back again"
"the other side of the mountain",
"C").
question2.check();
question2.showResults();

}

}

 

I am including the bugs and errors on the screenshots for Quiz.java to help with debugging the errors.  I have the answer sheet but I still need the lines mentioned to be debugged.

*/
6 public class Quiz {
7
80
public static void main(String[] args) {
MultipleChoiceQuestion question = new MultipleChoiceQuestion("What is a quiz?",
9.
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
"a test of knowledge, especially a brief informal test given to students",
"42",
"a duck",
"to get to the other side",
"To be or not to be, that is the question.",
"a");|
question.check();
question. showResults();
MultiplechoiceQuestion question1 = new MultipleChoiceQuestion("When is a quiz?"
"a long, long ago",
"right now",
"the best of times",
"the worst of times",
"nevermore", "b");
question1.check();
question1, showResults();
MultipleChoiceQuestion question2
MultipleChoice0Question("Nhere is a quiz?".
magalaxy far.ntaaway".
"under the sea".
26
27
28
29
= new
www
Transcribed Image Text:*/ 6 public class Quiz { 7 80 public static void main(String[] args) { MultipleChoiceQuestion question = new MultipleChoiceQuestion("What is a quiz?", 9. 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 "a test of knowledge, especially a brief informal test given to students", "42", "a duck", "to get to the other side", "To be or not to be, that is the question.", "a");| question.check(); question. showResults(); MultiplechoiceQuestion question1 = new MultipleChoiceQuestion("When is a quiz?" "a long, long ago", "right now", "the best of times", "the worst of times", "nevermore", "b"); question1.check(); question1, showResults(); MultipleChoiceQuestion question2 MultipleChoice0Question("Nhere is a quiz?". magalaxy far.ntaaway". "under the sea". 26 27 28 29 = new www
wwnder the seaA
29
30
31
O32
033
miight.hece".
nithere and back again"
wthe other side ef the mountain".
"C").
question2.check();
question2. showResults();
34
35
36
37
}
38
39 }
40
Problems
@ Javadoc e Console 3
Terminal e Console e Console
Coverage
x*| 物
<terminated> Quiz (1) [Java Application] C:\Users\Maria Caudle\.p2\pool\plugins\org.eclipse.justj.openjdk.hotspot.jre.full.win32.x86_64_16.0.2.v
Exception in thread "main" java.lang. Error: Unresolved compilation problems:
The constructor MultipleChoiceQuestion (String, String, String, String, String, String) is undefine
Syntax error on token ""the other side of the mountain"", delete this token
question2 cannot be resolved or is not a field
Transcribed Image Text:wwnder the seaA 29 30 31 O32 033 miight.hece". nithere and back again" wthe other side ef the mountain". "C"). question2.check(); question2. showResults(); 34 35 36 37 } 38 39 } 40 Problems @ Javadoc e Console 3 Terminal e Console e Console Coverage x*| 物 <terminated> Quiz (1) [Java Application] C:\Users\Maria Caudle\.p2\pool\plugins\org.eclipse.justj.openjdk.hotspot.jre.full.win32.x86_64_16.0.2.v Exception in thread "main" java.lang. Error: Unresolved compilation problems: The constructor MultipleChoiceQuestion (String, String, String, String, String, String) is undefine Syntax error on token ""the other side of the mountain"", delete this token question2 cannot be resolved or is not a field
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education