write a java program for Driving license test..The local SAAQ (Société de l’Aassurance automobile du Québec) has asked you to write a program that grades the written portion of the driver’s license test. The exam booklet has 5 multiple choice questions. Here are the correct answers (answer key) for questions numbered: 1. B 2. D 3. A 4. A 5. C Write a class named DriverExam whose objects, each of which maintains the data of a candidate, and the following are the private fields (field name in bold font): • a static constant integer field (totalQs) initialized to value 5 for total number of questions. It should be used instead of hard coding

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

write a java program for Driving license test..The local SAAQ (Société de l’Aassurance automobile du Québec) has asked you to write a program that grades the written portion of the driver’s license test. The exam booklet has 5 multiple choice questions. Here are the correct answers (answer key) for questions numbered:
1. B 2. D 3. A 4. A 5. C
Write a class named DriverExam whose objects, each of which maintains the data of a candidate, and the following are the private fields (field name in bold font):
• a static constant integer field (totalQs) initialized to value 5 for total number of questions. It should
be used instead of hard coding because SAAQ can easily increase questions in future.
• a static constant array of characters (answer) initialized to correct answer key given above.
• a static integer field (candidates) initialized to value 0 for the number of candidates taking exam
which should be incremented upon creating an object of DriverExam for a candidate.
• a string field (name) to hold the name of candidate.
• an integer field (sin) to hold the “Social Insurance Number (S.I.N.)” of candidate,
• a character array to hold actual answers of candidate (candidateAnswer) for the questions, and
• an integer field (score) initialized to value 0 for the number of questions answered correctly by
candidate.
The class should implement (i.e., define and write code) the following methods:
• DriverExam(String name, int sin) with two parameters for name and sin (S.I.N.) of candidate,
• get_totalQs() returns the value of totalQs,
• passed() returns true if the student passed the exam (i.e., 60% or more questions are answered
correctly), or false if the student failed. The method should first compare the candidate’s answers
with answer key and update the score field, then test the score field to return the result.
• get_name() returns the name of candidate,
• get_score() returns the score of candidate (i.e., the number of questions answered correctly),
• set_candidateAnswer(int question, char answer) sets an answer in candidateAnswer array for a specified question.

Write a driver program that uses DriverExam class, creates an array of “n” objects of DriverExam (e.g., integer “n=2” for two candidates) allows them to take the exam. The exam booklets are provided to candidates, so they can directly answer the multiple-choice questions (MCQs) one by one.
Use a for loop for conducting exams of candidates (i.e., DriverExam objects), prompting each candidate. Your program should ask each candidate to enter first name, last name, S.I.N., and “answers to MCQs in a for loop”. Once a candidate completes answering, the results should be printed. Your program should call appropriate methods. Please refer to the following screen shot for details.

8:37
( Back Mid-Term Exam (2.5 hours)
candidate to enter first name, la
MCQS in a for loop". Once a c
results should be printed. Your
methods. Please refer to the follov
Example screen shot 1:
Welcome to the Driver License Exam
Please enter your first name: Malleswara
Please enter your last name: Talla
Please enter your s.I.N. without spaces: 555666777
Please answer (A, B, C, D, or Q to quit) for each question.
Question # 1: B
Question # 2: D
Question # 3: A
Question # 4: A
Question # 5: c
Congratulations Malleswara Talla! You passed the exam!
Number of correct answers = 5
Number of wrong answers = 0
Good Bye!
Welcome to the Driver License Exam
Please enter your first name: Brian
Please enter your last name: McGregor
Please enter your S.I.N. without spaces: 333888111
Please answer (A, B, C, D, or Q to quit) for each question.
Question # 1: B
Question # 2: B
Question # 3: A
Question # 4: B
Question # 5: D
Sorry Brian McGregor! You failed the exam!
Number of correct answers = 2
Number of wrong answers - 3
Good Bye!
Total candidates = 2
Example screen shot 2:
Welcome to the Driver License Exam
Please enter your first name: Raja
Please enter your last name: Talla
Please enter your S.I.N. without spaces: 123666789
Please answer (A, B, C, D, or Q to quit) for each question.
Question # 1: B
Question # 2: D
Question # 3: A
Question # 4: Q
Congratulations Raja Talla! You passed the exam!
Number of correct answers = 3
Number of wrong answer = 2
%3D
Transcribed Image Text:8:37 ( Back Mid-Term Exam (2.5 hours) candidate to enter first name, la MCQS in a for loop". Once a c results should be printed. Your methods. Please refer to the follov Example screen shot 1: Welcome to the Driver License Exam Please enter your first name: Malleswara Please enter your last name: Talla Please enter your s.I.N. without spaces: 555666777 Please answer (A, B, C, D, or Q to quit) for each question. Question # 1: B Question # 2: D Question # 3: A Question # 4: A Question # 5: c Congratulations Malleswara Talla! You passed the exam! Number of correct answers = 5 Number of wrong answers = 0 Good Bye! Welcome to the Driver License Exam Please enter your first name: Brian Please enter your last name: McGregor Please enter your S.I.N. without spaces: 333888111 Please answer (A, B, C, D, or Q to quit) for each question. Question # 1: B Question # 2: B Question # 3: A Question # 4: B Question # 5: D Sorry Brian McGregor! You failed the exam! Number of correct answers = 2 Number of wrong answers - 3 Good Bye! Total candidates = 2 Example screen shot 2: Welcome to the Driver License Exam Please enter your first name: Raja Please enter your last name: Talla Please enter your S.I.N. without spaces: 123666789 Please answer (A, B, C, D, or Q to quit) for each question. Question # 1: B Question # 2: D Question # 3: A Question # 4: Q Congratulations Raja Talla! You passed the exam! Number of correct answers = 3 Number of wrong answer = 2 %3D
8:37
Back Mid-Term Exam (2.5 hours)
Good Bye!
Total candidates = 2
Example screen shot 2:
Welcome to the Driver License Exam
Please enter your first name: Raja
Please enter your last name: Talla
Please enter your S.I.N. without spaces: 123666789
Please answer (A, B, C, D, or Q to quit) for each question.
Question # 1: B
Question # 2: D
Question # 3: A
Question # 4: Q
Congratulations Raja Talla! You passed the exam!
Number of correct answers = 3
Number of wrong answers = 2
Good Bye!
Welcome to the Driver License Exam
Please enter your first name: Daniel
Please enter your last name: Smith
Please enter your S.I.N. without spaces: 444111222
Please answer (A, B, C, D, or Q to quit) for each question.
Question # 1: B
Question # 2: D
Question # 3: B
Question # 4: Q
Sorry Daniel Smith! You failed the exam!
Number of correct answers = 2
Number of wrong answers - 3
Good Bye!
Total candidates = 2
Transcribed Image Text:8:37 Back Mid-Term Exam (2.5 hours) Good Bye! Total candidates = 2 Example screen shot 2: Welcome to the Driver License Exam Please enter your first name: Raja Please enter your last name: Talla Please enter your S.I.N. without spaces: 123666789 Please answer (A, B, C, D, or Q to quit) for each question. Question # 1: B Question # 2: D Question # 3: A Question # 4: Q Congratulations Raja Talla! You passed the exam! Number of correct answers = 3 Number of wrong answers = 2 Good Bye! Welcome to the Driver License Exam Please enter your first name: Daniel Please enter your last name: Smith Please enter your S.I.N. without spaces: 444111222 Please answer (A, B, C, D, or Q to quit) for each question. Question # 1: B Question # 2: D Question # 3: B Question # 4: Q Sorry Daniel Smith! You failed the exam! Number of correct answers = 2 Number of wrong answers - 3 Good Bye! Total candidates = 2
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Similar questions
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