Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

(Java) Please follow the instructions at the bottom of the picture exactly Drive

ID: 3719421 • Letter: #

Question

(Java) Please follow the instructions at the bottom of the picture exactly

Driver License Online Test The local driver's license office has asked you to write a program that grades the written portion of the driver icense Rules and Signals Test. The driver license test has 25 multiple choice questions. The set of answer keys is: L.A 2.C 6.B 7.C 8.D 9.A 10.B 11.C 12.A 16.B 17.A 18.? 19.A 20.D 21.8 22.C 23.A 24.D 25.B 4.B S.D 14.C 15.A First, the application displays messages to ask for the information of current candidate about last name, first name, SS number to create a Test account When the canidate is ready, display the test instruction, questions and read answers THERE ARE 25 MULTIPLE CEOTCE QUESTEONS OU HAVE TO GET 20 CORRECT ANSKERS TO GET The users answer the question by typing a letter A, B, C or D for each question. If users type other keys than A, B, C or D; display message "Invalid key-Retype and allow users to retype the answer of current question before moving on All the answers and the key set should be sent to the Test account in array type to evaluate the result. The result will be displayed on the screen in the following format, where the date is current date and Driver's icense number is a combination of two random 4-digit numbers DRIVER LICENSE TEST RESULT Driver's name: SS Number Phone Number Smith, James 112233440 2141234567 123 Plano Rd Dallas TX 75243 12345678 03/15/2018 Driver's License Test date Result Missed Questions 5, 12, 15 program will be available for other candidates to test until users choose to exit ANALYSIS AND DESIGN Provide the UML of the data type class -Provide the pseudo-code of main) WHAT YOU NEED TO KNOW TO DO THE LAB How to declare a character array -How to access each number of array -How to print out values stored in an array -How -How to declare an object by calling parameter constructor to generate the current date HOW TO DO THE LAB -Create the project named SP2018LAB7_PART2 -Add the data type class named as SP2018LAB6_DriverCandidate yourName that includes two character arrays one is keySet defined as a constant character array storing the answers of the test and other one is answerSet that stores the answers entered from users. The class can store the method to count how many correct questions to determine the result passed or failed To report which questions are failed, you can define an int array with the same size and for each question correct mark 1 and failed mark0 The method toString will display the result as requested format -Add the driver class SP2018LAB6_GradingDLTest yourLastName then follow the pseudo-code to write the code of the program

Explanation / Answer

Code

import java.util.Scanner;
import java.util.Random;
import java.text.SimpleDateFormat;
import java.util.Date;
public class GradingDLTest {
   
    class DriverCandidate{
       
        String firstName;
        String lastName;
        String ssNumber;
        String phoneNumber;
        String address;
        String missedQuestion="";
int correctAnswer;
        public String getFirstName() {
return firstName;
}

public void setFirstName(String firstName) {
this.firstName = firstName;
}

public String getLastName() {
return lastName;
}

public void setLastName(String lastName) {
this.lastName = lastName;
}

public String getSsNumber() {
return ssNumber;
}

public void setSsNumber(String ssNumber) {
this.ssNumber = ssNumber;
}

public String getPhoneNumber() {
return phoneNumber;
}

public void setPhoneNumber(String phoneNumber) {
this.phoneNumber = phoneNumber;
}

public String getAddress() {
return address;
}

public void setAddress(String address) {
this.address = address;
}
       
        final char[] keySet = {'A','C','B','B','D','B','C','D','A','B','C','A','B','C','A','B','A','C','A','D','B','C','A','D','B'};
        char[] answerSet = new char[25];
        int[] evalAns = new int[25];
       
        public int countAnswers(){
            int correctAnswers = 0;
            for(int j=0;j<25;j++){
            if(answerSet[j] == keySet[j]){
                correctAnswers++;
                evalAns[j] = 1;
            }else{
                evalAns[j] = 0;
            }
        }
           
            return correctAnswers;
        }
        public String toString(){
int num1 = 0;
int num2 = 0;
StringBuffer sb = new StringBuffer();
String pattern = "MM/dd/yyyy";
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern);
Random rand = new Random();
if (correctAnswer >= 20) {
String result = "PASSED";
if (num1 < 999)
num1 = rand.nextInt(9999) + 1000;
if (num2 < 999)
num2 = rand.nextInt(9999) + 1000;
sb.append(" DRIVING LICENSE TEST RESULTS");
sb.append(" Driver's Name         :" + firstName + ", " + lastName);
sb.append(" SSN Number            :" + this.ssNumber);
sb.append(" Phone Number          :" + phoneNumber);
sb.append(" Address               :" + address);
sb.append(" Driver's License      :" + (num1 + "" + num2));
sb.append(" Test Date             :" + simpleDateFormat.format(new Date()));
sb.append(" Result                :" + result);
sb.append(" Misssed Question      :" + missedQuestion);
} else {
String result = "FAILED";
sb.append(" DRIVING LICENSE TEST RESULTS");
sb.append(" Driver's Name         :" + firstName + " " + lastName);
sb.append(" SSN Number            :" + ssNumber);
sb.append(" Phone Number          :" + phoneNumber);
sb.append(" Address               :" + address);
// System.out.println("Driver's License :" + (num1+""+num2));
sb.append("Test Date             :" + simpleDateFormat.format(new Date()));
sb.append(" Result                :" + result);
sb.append(" Misssed Question      :" + missedQuestion);
}

return sb.toString();
}
    }
   
    public static void main(String args[]) {
        String[] questionArray = new String[25];
       
       
        int i=0;
        for(i=0;i<25;i++){
            questionArray[i] = "Question " + (i+1) + " ";
        }
        char option = 0;
        do{
        Scanner scan = new Scanner(System.in);
        System.out.print("Enter First Name: ");
        String firstName = scan.nextLine();
        System.out.print("Enter Last Name: ");
        String lastName = scan.nextLine();
        System.out.print("Enter SS Number: ");
        String number = scan.nextLine();
        System.out.print("Enter Phone Number: ");
        String phonenumber = scan.nextLine();
        System.out.print("Enter Address: ");
        String address = scan.nextLine();
        DriverCandidate dc = new GradingDLTest().new DriverCandidate();
        dc.setFirstName(firstName);
        dc.setLastName(lastName);
        dc.setSsNumber(number);
        dc.setPhoneNumber(phonenumber);
        dc.setAddress(address);
       
        System.out.println("                DRIVING LICENSE TEST                   ");
        System.out.println("       THERE ARE 25 MULTIPLE CHOICE QUESTION           ");
        System.out.println("    YOU HAVE TO GET 20 CORRECT ANSWER TO GET PASSED    ");
        System.out.println("*******************************************************");
        i = 0;
        int correctAnswer = 0;
        String missedQuestion = "";
        do{
            System.out.println(questionArray[i]);
            while(true){
            System.out.print("Answer>>>");
            char answer = scan.next().charAt(0);
            if(answer == 'A' || answer == 'B'|| answer == 'C' || answer == 'D'){
             //if(answer==answerArray[i].charAt(0)){
                dc.answerSet[i] = answer;
             //}
             break;
            }
            else{
               System.out.println( " Input should be A, B , C or D");
            }
            }
            i++;
        }while(i<25);
       correctAnswer = dc.countAnswers();
       System.out.println(dc.toString());
       
       
        System.out.print("Do you want to take test again YES/NO:");
        option = scan.next().charAt(0);
        }while(option == 'Y');
    }
}

Output

Enter First Name: Vinoth

Enter Last Name: Sivakumar

Enter SS Number: 123456789

Enter Phone Number: 9876543210

Enter Address: Bangalore India

DRIVING LICENSE TEST

THERE ARE 25 MULTIPLE CHOICE QUESTION

YOU HAVE TO GET 20 CORRECT ANSWER TO GET PASSED   

*******************************************************

Question 1

Answer>>>A

Question 2

Answer>>>B

Question 3

Answer>>>C

Question 4

Answer>>>D

Question 5

Answer>>>A

Question 6

Answer>>>B

Question 7

Answer>>>C

Question 8

Answer>>>D

Question 9

Answer>>>A

Question 10

Answer>>>E

Input should be A, B , C or D

Answer>>>A

Question 11

Answer>>>B

Question 12

Answer>>>C

Question 13

Answer>>>D

Question 14

Answer>>>A

Question 15

Answer>>>C

Question 16

Answer>>>C

Question 17

Answer>>>C

Question 18

Answer>>>D

Question 19

Answer>>>A

Question 20

Answer>>>B

Question 21

Answer>>>A

Question 22

Answer>>>D

Question 23

Answer>>>A

Question 24

Answer>>>C

Question 25

Answer>>>A

DRIVING LICENSE TEST RESULTS

Driver's Name :Sivakumar, Vinoth

SSN Number :123456789

Phone Number :9876543210

Address :Bangalore India

Test Date :04/10/2018

Result :FAILED

Misssed Question :2, 3, 4, 5, 10, 11, 12, 13, 14, 15, 16, 17, 18, 20, 21, 22, 24, 25,

Do you want to take test again: Y / N:Y

Enter First Name: Smith

Enter Last Name: James

Enter SS Number: 112233440

Enter Phone Number: 3412567890

Enter Address: 123 Plano Rd Dallas TX 73152

DRIVING LICENSE TEST

THERE ARE 25 MULTIPLE CHOICE QUESTION

YOU HAVE TO GET 20 CORRECT ANSWER TO GET PASSED   

*******************************************************

Question 1

Answer>>>A

Question 2

Answer>>>C

Question 3

Answer>>>B

Question 4

Answer>>>B

Question 5

Answer>>>D

Question 6

Answer>>>B

Question 7

Answer>>>C

Question 8

Answer>>>D

Question 9

Answer>>>A

Question 10

Answer>>>B

Question 11

Answer>>>C

Question 12

Answer>>>A

Question 13

Answer>>>B

Question 14

Answer>>>C

Question 15

Answer>>>A

Question 16

Answer>>>B

Question 17

Answer>>>A

Question 18

Answer>>>C

Question 19

Answer>>>A

Question 20

Answer>>>D

Question 21

Answer>>>D

Question 22

Answer>>>D

Question 23

Answer>>>A

Question 24

Answer>>>D

Question 25

Answer>>>B

DRIVING LICENSE TEST RESULTS

Driver's Name :Smith James

SSN Number :112233440

Phone Number :3412567890

Address :123 Plano Rd Dallas TX 73152

Driver's License :296610633

Test Date :04/10/2018

Result :PASSED

Misssed Question :21, 22,

Do you want to take test again: Y / N:N