Java problem. Use at least two methods in the program. Use an array parameter in
ID: 3842477 • Letter: J
Question
Java problem.
Use at least two methods in the program.
Use an array parameter in a method that uses call by reference when assigning values to the array.
Write a program that grades the multiple choice drivers’ license e/xam.
The e/xam has the following answer key:
1. B 2. D 3. A 4. A 5. C 6. A 7. B 8. A 9. C 10. D
11. B 12. C 13. D 14. A 15. D 16. C 17. C 18. B 19. D 20. A
The program will input a person’s answers and display the percent correct along with a message whether they passed or failedthe test. Use the following methods:
public static void getExamData(char responses[])
that will let the user input the 20 values
public static boolean passed(int numCorrect)
that returns true if they answer at least 15 out of the 20 correctly.
public static int totalCorrect(char responses[])
returns the number of correct answers using an array containing the answer key.
Use a global constant in the program called PASSING_SCORE and set it to 15.
Turn in the following runs:
1) A A A A A A A A A A A A A A A A A A A A
2) B D A A C A B A C D B C D A D C C B D A
3) A A B B A B A B A A A A A B A A A A A B
Explanation / Answer
//class class DriverExam { private char[] key = { 'B', 'D', 'A', 'A', 'C', 'A', 'B', 'A', 'C', 'D', 'B', 'C', 'D', 'A', 'D', 'C', 'C', 'B', 'D', 'A' }; private char[] answers; public DriverExam(char[] ans) { answers = ans; } public boolean passed () { return (totalCorrect() > 14); } public int totalCorrect() { int correct = 0; for (int i = 0; iRelated Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.