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

The local Driver\'s License Office has asked you to write a program that grades

ID: 3676633 • Letter: T

Question

The local Driver's License Office has asked you to write a program that grades the written portion of the driver's license exam. The exam has 20 multiple choice question Here are correct answers Your program should store the correct answers shown above in array. It should ask the user to enter the student's answers for each of the 20 questions, and the answers should be stored in another array. After the student's answers have entered, the program should display a message indicating whether the student passed or farted the exam, it should must correctly answer 15 of the 20 question to pass the exam. if should then display the total number of correctly answered questions, the total number incorrectly answered questions, and a list showing the question numbers of the incorrectly answered question Input Validation: Only accept the letters A.B,C or D as answer MUST use functions MUST use arrays

Explanation / Answer

#include <iostream>
using namespace std;

void readAnswers(char answers[], int arrlen) {
   int i = 0;
   for(i = 0; i < arrlen; i++) {
       cout << "Enter answer(A/B/C/D) for question No#" << (i+1) << ":" <<endl;
       cin >> answers[i];
   }
}

void validateAnswers(char answers[], char stdanswers[], int arrlen) {
   int result[arrlen];
   int i = 0;
   int correctAns = 0;
   for(i = 0; i < arrlen; i++) {
       if(answers[i] == stdanswers[i]) {
           result[i] = 1;
           correctAns++;
       }
       else
           result[i] = 0;
   }

   //display the results
   cout << "Total number of correct answers:" << correctAns <<endl;
   cout << "Total number of wrong answers:" << (arrlen-correctAns) <<endl;
    cout << "Question numbers which are wrongly answered:"<<endl;
    for(i = 0; i < arrlen; i++) {
       if(result[i] == 0)
           cout << (i+1) << " ";
    }
    cout <<endl;

}
int main() {
   char answers[] = {'B','D','A','A','C','A','B','A','C', 'D',
                     'B', 'C','D','A','D','C','C','B','D','A'};

   char stdanswers[20];

   readAnswers(stdanswers,20);
   validateAnswers(answers, stdanswers,20);
   return 1;
}


---output----

Enter answer(A/B/C/D) for question No#1:
A
Enter answer(A/B/C/D) for question No#2:
B
Enter answer(A/B/C/D) for question No#3:
A
Enter answer(A/B/C/D) for question No#4:
B
Enter answer(A/B/C/D) for question No#5:
C
Enter answer(A/B/C/D) for question No#6:
D
Enter answer(A/B/C/D) for question No#7:
E
Enter answer(A/B/C/D) for question No#8:
A
Enter answer(A/B/C/D) for question No#9:
B
Enter answer(A/B/C/D) for question No#10:
C
Enter answer(A/B/C/D) for question No#11:
D
Enter answer(A/B/C/D) for question No#12:
A
Enter answer(A/B/C/D) for question No#13:
B
Enter answer(A/B/C/D) for question No#14:
C
Enter answer(A/B/C/D) for question No#15:
D
Enter answer(A/B/C/D) for question No#16:
D
Enter answer(A/B/C/D) for question No#17:
C
Enter answer(A/B/C/D) for question No#18:
B
Enter answer(A/B/C/D) for question No#19:
A
Enter answer(A/B/C/D) for question No#20:
A
Total number of correct answers:7
Total number of wrong answers:13
Question numbers which are wrongly answered:
1 2 4 6 7 9 10 11 12 13 14 16 19