Question: - Question text file : public class Question { private String text; // the question private String a, b, c, d; // the possible answers

- Question text file :

public class Question {

private String text; // the question

private String a, b, c, d; // the possible answers

private char answer; // the character for the correct answer

public Question(String choicea, String choiceb, String choicec, String choiced, char ans) {

a=choicea;

b=choiceb;

c=choicec;

d=choiced;

answer = ans;

}

public Question(java.util.Scanner sc) {

text = sc.nextLine();

a = sc.nextLine();

b = sc.nextLine();

c = sc.nextLine();

d = sc.nextLine();

answer = sc.nextLine().trim().toLowerCase().charAt(0);

}

public String toString() {

return text + " a. " + a + " b. " + b + " c. " + c + " d. " + d;

}

public String getA() {

return a;

}

public String getB() {

return b;

}

public String getC() {

return c;

}

public String getD() {

return d;

}

public char getAnswer() {

return answer;

}

public boolean isCorrect(char ch) {

return answer==ch;

}

}

- the Quiz text file:

Formed on a diskette (or hard drive) during initialization. source code images sectors storage units c The CPU consists of: Control Unit, Temporary Memory, Output Control Unit, Arithmetic Logic Unit, Temporary Memory Input, Process, Storage, Output Input, Control Unit, Arithmetic Logic Unit, Output b OOP stands for: Observable Object Programming Object Observed Procedures Object Oriented Programming Object Overloading Practices c Output printed on paper. softcopy hardcopy source code software b A binary digit (1 or 0) signifying "on" or "off". bit byte megabyte gigabyte a Our decimal number 44, when represented in binary, is: 101100 101010 111000 10100 a Byte code is the machine language for a hypothetical computer called the: Java Byte Code Compiler Java Byte Code Interpreter Java Virtual Machine Java Memory Machine c Equals 8 bits. megabyte gigabyte sector byte d Java allows for three forms of commenting: // single line, ** block lines, /*/ documentation // single line, /*...*/ block lines, /**...*/ documentation / single line, /* block lines, ** documentation // single line, //...// block lines, //*...*// documentation b To prepare a diskette (or hard drive) to receive information. format track interpret boot a In Java, the name of the class must be the same as the name of the .java file. false true - but case sensitivity does not apply true - but additional numbers may be added to the name true d The name Java was derived from a cup of coffee an acronym for JBuilder Activated Variable Assembly an acronym for Juxtapositioned Activated Variable Actions an acronym for John's Answer for Various Accounts a Programs that tell a computer what to do. harware software hard copy projects b RAM stands for _________. Read Anytime Memory Read Allocated Memory Random Access Memory Random Allocated Memory c Several computers linked to a server to share programs and storage space. library grouping network integrated system c The four equipment functions of a computer system. Input, Process, Control Unit, Output Input, Control Unit, Arithmetic Logic Unit, Output Input, Process, Storage, Output Input, Process, Library Linking, Output c Translates and executes a program line by line. compiler interpreter linker control unit b The physical components of a computer system. control unit hardware software ALU b

Quiz class
Instructions

Given the attached Question class and quiz text, write a driver program to input the questions from the text file, print each quiz question, input the character for the answer, and, after all questions, report the results.

Write a Quiz class for the driver, with a main method.

There should be a Scanner field for the input file, a field for the array of Questions (initialized to 100 possible questions), and an int field for the actual number of questions.

The constructor should instantiate the Question array, open the file with the Scanner, and input the Question array from the input file. Note that one of the constructors for the Question class takes a Scanner parameter and initializes an entire question from the Scanner. There is a blank line at the end of the file, so hasNextLine() would work for the loop. After the input loop, the count field should be the number of questions.

A give() method should declare and instantiate a Scanner for keyboard input, counters for correct and incorrect answers, an array (or ArrayList) of ints for the numbers that were incorrect, and an array (or ArrayList) of chars for the answers that were incorrect. It should loop through each question and print it out, prompt for the answer, count it if it is right and save the question number and wrong answer in the two arrays (or ArrayLists) if it is wrong. After this loop, it should print out the number correct and the numbers that were wrong, with the wrong answers.

The main method should just instantiate a Quiz and call its give() method.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!