1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
|
#include <iostream>
using namespace std;
//Brandon Skar. 11/13/2016. Driver's License Exam
int main()
{
int row = 0, col = 0, score = 0;
char examScore[5][4];
char examAnswers[5][4] = { {'A', 'B', 'A', 'C'},
{'D', 'A', 'C', 'C'},
{'B', 'B', 'D', 'A'},
{'B', 'C', 'B', 'D'},
{'C', 'D', 'D', 'B'} };
cout << "Enter answers A, B, C, D (case sensitive)" << endl;
for (int count = 0; count < 20;)
{
while (col < 4)
{
while (row < 5)
{
cout << "Answer for Question " << (count + 1) << ": ";
cin >> examScore[row][col];
if (examScore[row][col] != 'A' && examScore[row][col] != 'B' && examScore[row][col] != 'C' && examScore[row][col] != 'D')
{
cout << "Invalid Input, Please Try Again.\n" << endl;
system("pause");
return 0;
}
row++;
count++;
}
col++;
row = 0;
}
}
row = 0, col = 0;
while (col < 4)
{
while (row < 5)
{
if (examScore[row][col] == examAnswers[row][col])
{
score += 1;
}
row++;
}
col++;
}
cout << score << endl;
system("pause");
return 0;
}
| |