In this assignment, you are required to implement an electronic programming quiz system. User can create questions and preview the quiz.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Description
In this assignment, you are required to implement an electronic programming quiz system. User can create
questions and preview the quiz.
Your Task
You are asked to write a Java program for the programming quiz system. There are two types of questions:
Multiple Choice Question and Ture/False Question. User can create questions using the system; and
preview the quiz, which display all questions in the system one by one. During the preview, the user can
attempt the quiz by entering his/her answers to questions. The system will then immediately check the
answer and calculate. After attempting all questions, the total score will be displayed. A sample run of the
program is shown as below (Green text refers to user input): 

Please choose (c)reate a question, (p)review or (e)xit >> c
Enter the type of question (MC or TF) >> MC
Enter the question text >> Each primitive type in Java has a corresponding
class contained in the java.lang package. These classes are called ____
classes.
How many options? 4
Enter Option A (Start with * for correct answer) >> case
Enter Option B (Start with * for correct answer) >> primitive
Enter Option C (Start with * for correct answer) >> *type-wrapper
Enter Option D (Start with * for correct answer) >> show
How many points? 3
Please choose (c)reate a question, (p)review or (e)xit >> c
Enter the type of question (MC or TF) >> MC
Enter the question text >> A(n) ____ variable is known only within the
boundaries of the method.
How many options? 5
Enter Option A (Start with * for correct answer) >> method
Enter Option B (Start with * for correct answer) >> *local
Enter Option C (Start with * for correct answer) >> double
Enter Option D (Start with * for correct answer) >> instance
Enter Option E (Start with * for correct answer) >> global
How many points? 2
Please choose (c)reate a question, (p)review  or (e)xit >> c
Enter the type of question (MC or TF) >> TF

Enter the question text >> Java is a free-form programming language.
Answer is True or False? True
How many points? 1
Please choose (c)reate a question, (p)review or (e)xit >> p
Each primitive type in Java has a corresponding class contained in the
java.lang package. These classes are called ____ classes. (3.0 Points)
A: case
B: primitive
C: type-wrapper
D: show
Enter your choice >> A
You are wrong. The correct answer is C.
A(n) ____ variable is known only within the boundaries of the method. (2.0
Points)
A: method
B: local
C: double
D: instance
E: global
Enter your choice >> B
You are correct!
Java is a free-form programming language. (1.0 Points)
True(T) or False(F) >> F
You are wrong. The correct answer is true.
The quiz ends. Your score is 2.0.
Please choose (c)reate a question, (p)review or (e)xit >> c
Enter the type of question (MC or TF) >> MC
Enter the question text >> A(n) ____ constructor is one that requires no
arguments.
How many options? 3
Enter Option A (Start with * for correct answer) >> class
Enter Option B (Start with * for correct answer) >> *default
Enter Option C (Start with * for correct answer) >> explicit
How many points? 2
Please choose (c)reate a question, (p)review or (e)xit >> c
Enter the type of question (MC or TF) >> TF
Enter the question text >> Javascript and Java are the same.
Answer is True or False? False
How many points? 0.5
Please choose (c)reate a question, (p)review or (e)xit >> p
Each primitive type in Java has a corresponding class contained in the
java.lang package. These classes are called ____ classes. (3.0 Points)
A: case
B: primitive
C: type-wrapper
D: show

Enter your choice >> C
You are correct!
A(n) ____ variable is known only within the boundaries of the method. (2.0
Points)
A: method
B: local
C: double
D: instance
E: global
Enter your choice >> B
You are correct!
Java is a free-form programming language. (1.0 Points)
True(T) or False(F) >> T
You are correct!
A(n) ____ constructor is one that requires no arguments. (2.0 Points)
A: class
B: default
C: explicit
Enter your choice >> C
You are wrong. The correct answer is B.
Javascript and Java are the same. (0.5 Points)
True(T) or False(F) >> T
You are wrong. The correct answer is false.
The quiz ends. Your score is 6.0.
Please choose (c)reate a question, (p)review or (e)xit >> e
Goodbye! 

 

Question Class:
- This class represents the generic form of question. It contains the question text (qText) and
the point of a question (point).
- The grade method, which is an abstract method, has a parameter, answer (String). It returns
the points of the question if the answer is correct; zero otherwise.
- The getCorrectAnswer method, which is an abstract method, has no parameter. It returns a
String representing the correct answer to the question.
MCQuestion Class
- It is a subclass of Question.
- It represents a multiple-choice question. A multiple-choice question may have 3-5 options.
- Each element of the instance variable options refers to an option in this question.
- The instance variable answer is a single-character string. It saves the correct answer (“A”,
“B”, “C”, “D” or “E”) to this question.

 

 

 

 

 

 

 

 

 

 

Assignment #3
Winter 2022
Question
qText : String
point : double
+Question()
+Question(String qText)
rgetqText() : String
+setqText(String qText) : void
getPoint() : double
+setPoint(double point): void
+grade(String answer) : double
rgetCorrectAnswer() : String
MCQuestion
TFQuestion
options : ArrayList<String>
-answer : boolean
Fanswer : String
+MCQuestion()
+MCQuestion(String qText, String options, double point)
+getOptions() : ArrayList<String>
+setOptions(ArrayList<String> options) : void
+setOptions(String options) : void
getAnswer() : String
+setAnswer(String answer) : void
TFQuestion()
+TFQuestion(String qText, boolean answer, double point)
getAnswer() : boolean
+setAnswer(String answer) : void
Question Class:
This class represents the generic form of question. It contains the question text (qText) and
the point of a question (point).
The grade method, which is an abstract method, has a parameter, answer (String). It returns
the points of the question if the answer is correct; zero otherwise.
The getCorrectAnswer method, which is an abstract method, has no parameter. It retums a
String representing the correct answer to the question.
MCQuestion Class
It is a subclass of Question.
It represents a multiple-choice question. A multiple-choice question may have 3-5 options.
Each element of the instance variable options refers to an option in this question.
The instance variable answer is a single-character string. It saves the correct answer ("A",
"B", "C", "D" or "E") to this question.
Page 4 of 9
Transcribed Image Text:Assignment #3 Winter 2022 Question qText : String point : double +Question() +Question(String qText) rgetqText() : String +setqText(String qText) : void getPoint() : double +setPoint(double point): void +grade(String answer) : double rgetCorrectAnswer() : String MCQuestion TFQuestion options : ArrayList<String> -answer : boolean Fanswer : String +MCQuestion() +MCQuestion(String qText, String options, double point) +getOptions() : ArrayList<String> +setOptions(ArrayList<String> options) : void +setOptions(String options) : void getAnswer() : String +setAnswer(String answer) : void TFQuestion() +TFQuestion(String qText, boolean answer, double point) getAnswer() : boolean +setAnswer(String answer) : void Question Class: This class represents the generic form of question. It contains the question text (qText) and the point of a question (point). The grade method, which is an abstract method, has a parameter, answer (String). It returns the points of the question if the answer is correct; zero otherwise. The getCorrectAnswer method, which is an abstract method, has no parameter. It retums a String representing the correct answer to the question. MCQuestion Class It is a subclass of Question. It represents a multiple-choice question. A multiple-choice question may have 3-5 options. Each element of the instance variable options refers to an option in this question. The instance variable answer is a single-character string. It saves the correct answer ("A", "B", "C", "D" or "E") to this question. Page 4 of 9
Assignment #3
Winter 2022
The method setoptions (String options) has the answer field from the database
(explained below) as the parameter. It will add all options to the instance variable options
and set the instance variable answer.
The constructor MCQuestion(String qText, String options, double point)
creates an MCQuestion object by setting the qText, adding option to options , setting the
correctAnswer to answer and point by reading the QText, Answer, and Point fields from
the database,
The grade method returns the points of the question if the parameter, which can be "A", "B",
"C", .., is equal to the instance variable answer, zero otherwise.
The getCorrectAnswer method returns the letter (i.e. "A", "B", "C", ...) representing the
correct answer.
TFQuestion Class
It is a subclass of Question.
It presents a True/False question.
The instance variable answer is a boolean variable representing the correct answer of the
question (i.e., True or False).
The constructor TFQuestion(String qText, boolean answer, double point)
creates an TFQuestion object by setting the qText, answer, and point by reading the
qText, Answer, and Point fields from the database.
The grade method returns the points of the question if the parameter, which can be "T" or
"F", is equal to the instance variable answer, zero otherwise.
The getCorrectAnswer method returns the letter "T" or "F" representing the correct answer.
3. You must read/write from/to the database provided in this question (Question.accdb). This MS
Access file contains a table called Questions. It contains the following fields:
a. ID (Automatically generated integer by MCAccess)
b. QText (Short Text): The question text
c. Answer (Short Text):
i. If this is a multiple-choice question, Answer stores all options separated by "#".
There is a leading *** for the correct option.
i1. If this is a True/False question, Answer stores the string "Ture" or "False".
d. Point (Single): It is a float point number representing the point of this question.
e. Type (Short Text): "MC" or "TF" denoting multiple-choice or True/False questions
respectively.
4. Question.accdb contains no record at the beginning.
5. You must create a class Asgn03, which has the main method to run the program.
6. Refer to the following screenshots for the data format saved in the database.
Page 5 of 9
Transcribed Image Text:Assignment #3 Winter 2022 The method setoptions (String options) has the answer field from the database (explained below) as the parameter. It will add all options to the instance variable options and set the instance variable answer. The constructor MCQuestion(String qText, String options, double point) creates an MCQuestion object by setting the qText, adding option to options , setting the correctAnswer to answer and point by reading the QText, Answer, and Point fields from the database, The grade method returns the points of the question if the parameter, which can be "A", "B", "C", .., is equal to the instance variable answer, zero otherwise. The getCorrectAnswer method returns the letter (i.e. "A", "B", "C", ...) representing the correct answer. TFQuestion Class It is a subclass of Question. It presents a True/False question. The instance variable answer is a boolean variable representing the correct answer of the question (i.e., True or False). The constructor TFQuestion(String qText, boolean answer, double point) creates an TFQuestion object by setting the qText, answer, and point by reading the qText, Answer, and Point fields from the database. The grade method returns the points of the question if the parameter, which can be "T" or "F", is equal to the instance variable answer, zero otherwise. The getCorrectAnswer method returns the letter "T" or "F" representing the correct answer. 3. You must read/write from/to the database provided in this question (Question.accdb). This MS Access file contains a table called Questions. It contains the following fields: a. ID (Automatically generated integer by MCAccess) b. QText (Short Text): The question text c. Answer (Short Text): i. If this is a multiple-choice question, Answer stores all options separated by "#". There is a leading *** for the correct option. i1. If this is a True/False question, Answer stores the string "Ture" or "False". d. Point (Single): It is a float point number representing the point of this question. e. Type (Short Text): "MC" or "TF" denoting multiple-choice or True/False questions respectively. 4. Question.accdb contains no record at the beginning. 5. You must create a class Asgn03, which has the main method to run the program. 6. Refer to the following screenshots for the data format saved in the database. Page 5 of 9
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY