
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](https://content.bartleby.com/qna-images/question/2b3e0ad1-27e4-45d5-9d4c-cf1a19e4c930/eaed9915-3226-44fe-9c0c-a925d2372cc9/uhwp0ja_thumbnail.jpeg)
![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](https://content.bartleby.com/qna-images/question/2b3e0ad1-27e4-45d5-9d4c-cf1a19e4c930/eaed9915-3226-44fe-9c0c-a925d2372cc9/xh02d7_thumbnail.jpeg)

Trending nowThis is a popular solution!
Step by stepSolved in 2 steps

- Write The Use Of Package.arrow_forwardUse the "College" data set from the package "ISLR", do the following: Get familiar with the data set. How many variables the data set has? What is the class of the variable "Private"? Add a new column "Enroll.rate" which is the ratio of Enroll v.s. Accept, to the data set. What are the top 10 Universities in terms of "Enroll.rate" (highest student enrollment ratio)? Get a new data frame "Mysubset" with all rows with an "Outstate" fee between 8000-9000 USD. solve using r codearrow_forwardAs the first step in writing an application for the local book store, we will design and implement a Book class that will define the data structure of the application. Each book has a name, author, type (paperback, hardback, magazine), integer ID and pageCount. Provide some data validation in the appropriate method to ensure that the ID and pageCount are not negative. Design and implement a Book class with separation, i.e., separate all functions and methods into both the prototype and an implementation below the main. Provide constructor methods for Book(void), Book(name, author), and one for all components Book(name, author, type, ID, pageCount) Provide accessor (get and set) methods for each property as well as a display method. Provide data validation for the ID and pageCount in the appropriate methods. Provide a method to calculate the cost for buying books (with a 7.75% sales tax) according to the following chart: Hardcover: $29.95 per book Paperback:…arrow_forward
- You have to use comment function to describe what each line does import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; import java.util.List; public class PreferenceData { private final List<Student> students; private final List<Project> projects; private int[][] preferences; private static enum ReadState { STUDENT_MODE, PROJECT_MODE, PREFERENCE_MODE, UNKNOWN; }; public PreferenceData() { super(); this.students = new ArrayList<Student>(); this.projects = new ArrayList<Project>(); } public void addStudent(Student s) { this.students.add(s); } public void addStudent(String s) { this.addStudent(Student.createStudent(s)); } public void addProject(Project p) { this.projects.add(p); } public void addProject(String p) { this.addProject(Project.createProject(p)); } public void createPreferenceMatrix() { this.preferences = new…arrow_forwardQUESTION 3 Which of the following is true about Introduce parameter object refactoring technique?1. Does not work with Java2. The technique is used to increase performance as it requires less memory3. You will need to create a new structure (class) for the grouped data if that structure does not already exist 4.Used to to shorten methodsarrow_forwardAssume the base package for an Eclipse project is edu.westga.cs1301.drinks and that you are writing tests for the dispense method of a DrinkMachine class. Use this information to answer the following questionWhat should you name your test class?arrow_forward
- Complete the docstring using the information attached (images):def upgrade_stations(threshold: int, num_bikes: int, stations: List["Station"]) -> int: """Modify each station in stations that has a capacity that is less than threshold by adding num_bikes to the capacity and bikes available counts. Modify each station at most once. Return the total number of bikes that were added to the bike share network. Precondition: num_bikes >= 0 >>> handout_copy = [HANDOUT_STATIONS[0][:], HANDOUT_STATIONS[1][:]] >>> upgrade_stations(25, 5, handout_copy) 5 >>> handout_copy[0] == HANDOUT_STATIONS[0] True >>> handout_copy[1] == [7001, 'Lower Jarvis St SMART / The Esplanade', \ 43.647992, -79.370907, 20, 10, 10] True """arrow_forwardUse an appropriate scikit-learn library we used in class to create y_train, y_test, X_train and X_test by splitting the data into 70% train and 30% test datasets. Set random_state to 4 and stratify the subsamples so that train and test datasets have roughly equal proportions of the target's class labels Standardise the data using StandardScaler libraryarrow_forwardTODO 2 Complete the TODO by finding the locations of the data samples for each iris flower type. Hint: Use the code for how we found all the setosa_locs as an example! Using iris_df, find the location of all the data sample locations for the versicolor class which has a label of 1. To do so, use NumPy's np.where() function. Using iris_df, find the location of all the data sample locations for the virginica class which has a label of 2. To do so, use NumPy's np.where() function. setosa_locs = np.where(iris_df['class'] == 0)[0] # TODO 2.1versicolor_locs = # TODO 2.2virginica_locs = todo_check([ (type(versicolor_locs) is np.ndarray, "'versicolor_locs' is not type np.ndarray. Make sure you indexed np.where() currently!"), (type(virginica_locs) is np.ndarray, "'virginica_locs' is not type np.ndarray. Make sure you indexed np.where() currently!"), (versicolor_locs[0] == 50, "'versicolor_locs' has an incorrect value"), (virginica_locs[0] == 100, "'virginica_locs' has an…arrow_forward
- Study the Table class and write a JUnit test class TableTest.java to test the Table class as follows. Submit the test class and screen captures showing pass of all the tests. Either JUnit4 or JUnit 5 in any IDE may be used. >>Table class code is in previous question a. Test findIndex() for an non-existing entry.b. Test findIndex() for an existing entry.c. Test put() for an non-existing entry.d. Test put() for an existing entrye. Test put() for a new entry putting into the full table.arrow_forwardAssume that all source files are in the same package. Note that some lines may wrap, but are still considered on one line. Examine the code below. Recall that variables have four kinds of scope: static, instance, local, and block. For each variable listed below, identify its scope (static, instance, local, or block) and describe the scope using complete sentences. An example description is provided, after the code listing, for the ounces variable in the Beverage2 class. Please describe the scope for the following variables: The num variable in the Beverage2 class The price variable in the Beverage2 class The shots variable in the Espresso class The b variable in the TestBeverage2 class The j variable in the TestBeverage2 class public abstract class Beverage2 { private static int num; private int ounces; private double price; protected Beverage2(int ounces, double price) { this.ounces = ounces; this.price = price;…arrow_forwardGenerate the Javadoc file for your project?arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education





