Driver’s License Exam The local driver’s license office has asked you to create an application that grades the written portion of the driver’s license exam.
Explanation:
- The exam has 20 multiple-choice questions. Here are the correct answers: 1. A 6. B 11. A 16. C 2. C 7. C 12. D 17. B 3. A 8. A 13. C 18. B 4. A 9. C 14. A 19. D 5. D 10. B 15. D 20. A Your program should store these correct answers in a list.
- The program should read the student’s answers for each of the 20 questions from a text file and store the answers in another list.
import java.util.*;
class DriverExam{
char[] answer = new char[]{ 'B','D','A','A','C','A','B','A','C','D','B','C','D','A','D','C','C','B','D','A'};
int correct=0,inCorrect=0;
int[] missed = new int[20];
boolean passed(){
if(this.correct >= 15){
return true;
}
return false;
}
int totalCorrect(){
return this.correct;
}
int totalIncorrect(){
return this.inCorrect;
}
int[] questionsMissed(){
return this.missed;
}
}
public class Main
{
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.println("Input : A,B,C,D");
System.out.println("Note : Any other inputs will result in skipping that question");
DriverExam exam = new DriverExam();
int i,missedIndex=0;
for(i=0;i<20;i++){
System.out.print("Answer "+(i+1)+" : ");
char check = in.next().charAt(0);
if(exam.answer[i]==check){
(exam.correct)++;
}