The local Driver’s License office has asked you to write a program that grades the written portion of the driver’s license exams. The exam has 10 multiple choice questions. Here are the correct answers. 1. A 2. D 3. B 4. B 5. C 6. B 7. A 8. B 9. C 10. D Your program should store the correct answers above in an array. It should ask the user to enter the student’s answers for each of the 10 questions, and the answers should be stored in another array. After the student’s answers have been entered, the program should display a message indicating whether the student passed or failed the exam. (A student must answer 8 of the 10 questions to pass the exam.) It should then display the total number of correctly answered questions, the total number of incorrectly answered questions, and a list showing the question numbers of the incorrectly answered questions. Input Validation: Only accept the letters A, B, C, or D as answers.

Grading the written portion of the driver’s license exam can be efficiently done with a program. The program should store the correct answers in an array and prompt the user to enter the student’s answers for each question, storing them in another array. Following this, the program should determine whether the student passed or failed the exam, display the total number of correctly and incorrectly answered questions, and provide a list showing the question numbers of the incorrectly answered questions. Input validation should be implemented to only accept the letters A, B, C, or D as answers.

To begin, we can start by declaring and initializing two arrays: one for the correct answers and another for the student’s answers. We can use the following code snippet as an example:

“`C++
char correctAnswers[] = {‘A’, ‘D’, ‘B’, ‘B’, ‘C’, ‘B’, ‘A’, ‘B’, ‘C’, ‘D’};
char studentAnswers[10];

“`

Next, we can prompt the user to enter the student’s answers for each question. We can use a loop to iterate through each question, requesting the answer from the user and storing it in the corresponding element of the studentAnswers array. Here’s an example of how this can be achieved:

“`C++
for (int i = 0; i < 10; i++) { cout << "Enter your answer for question " << (i + 1) << ": "; cin >> studentAnswers[i];

// Input validation
while (studentAnswers[i] != ‘A’ && studentAnswers[i] != ‘B’ &&
studentAnswers[i] != ‘C’ && studentAnswers[i] != ‘D’)
{
cout << "Invalid answer! Please enter A, B, C, or D: "; cin >> studentAnswers[i];
}
}
“`

After the student’s answers have been entered, we can calculate the results. This involves comparing each element of the studentAnswers array with the corresponding element of the correctAnswers array. By keeping track of the number of correctly and incorrectly answered questions, we can determine if the student passed or failed the exam. We can use the following code snippet as an example:

“`C++
int numCorrect = 0;
int numIncorrect = 0;
vector incorrectQuestions;

for (int i = 0; i < 10; i++) { if (studentAnswers[i] == correctAnswers[i]) { numCorrect++; } else { numIncorrect++; incorrectQuestions.push_back(i + 1); } } bool passed = (numCorrect >= 8);
“`

Finally, we can display the results to the user. We can output whether the student passed or failed the exam, along with the total number of correctly and incorrectly answered questions. Additionally, we can provide a list of the question numbers that the student answered incorrectly. Here’s an example of how this can be done:

“`C++
cout << "Exam Results:" << endl; cout << "Passed: " << (passed ? "Yes" : "No") << endl; cout << "Correctly answered questions: " << numCorrect << endl; cout << "Incorrectly answered questions: " << numIncorrect << endl; if (numIncorrect > 0) {
cout << "Incorrectly answered question numbers: "; for (int i = 0; i < incorrectQuestions.size(); i++) { cout << incorrectQuestions[i] << " "; } cout << endl; } ``` By following this approach, you can create a program that efficiently grades the written portion of the driver's license exams, providing the necessary feedback to the user. It's important to include input validation to ensure that only valid answers are accepted.

Need your ASSIGNMENT done? Use our paper writing service to score better and meet your deadline.


Click Here to Make an Order Click Here to Hire a Writer