hi, I know it's me again.
It's HW, and I'm supposed to write a program that grades an example of 20 questions. I'm supposed to store the correct answers in an array. And then ask the user to enter the student's answers for each of the 20 questions, whic should be stored in another array. Then if the student got more than 15 questions right, I have to display a message that says "PASS". Moreover, if the choices they enter is not A, B, C, or D, I have to tell them to enter it again.
So far, I only got to the part where student has to enter his answer, but I don't know how to do it, since it a two dimensational array.
can anyone help?
this is my code so far
//driver's license Exam
#include <iostream.h>
void StudentAns(char [20][2]);
char choice, A, B, C, D;
void main(void)
{
char key[20][2] = { {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, 'B'}, {18, 'B'}, {19, 'D'}, {20, 'A'} };
StudentAns(key);
}
void StudentAns(char answer[20][2])
{
for (int quest = 1; quest <=20; quest++)
{
cout << "Please enter your choice for Question " << quest << endl;
cin >> choice;
do
{
cout << "You must enter A, B, C, or D.\n";
cin >> choice;
}while (choice !='A'|| choice != 'B'|| choice != 'C' || choice != 'D');
}
}