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 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
|
#include<iostream>
#include<string>
using namespace std;
class TestGrade
{
public: void setKey(char []);
void grade(char []);
char canswers[20];
void display();
};
void TestGrade::setKey(char answers[])
{
for(int index = 0; index < 19; index++)
{
canswers[index] = answers[index];
}
}
void TestGrade::grade(char answer[])
{
for(int index = 0; index < 19; index++)
{
cout << canswers[index] << " " << answer[index] << endl;
}
}
void TestGrade::display()
{
{for (int index = 0; index < 19;index++)
{
cout << canswers[index] << endl;}
}
}
int main()
{
const char SIZE = 20;
char answer[SIZE];
char key[20] = {'B', 'D', 'A', 'A',
'C', 'A', 'B', 'A',
'C', 'D', 'B', 'C',
'D', 'A', 'D', 'C',
'C', 'B', 'D', 'A'};
TestGrade test1,test2;
test1.setKey(key);
cout << "Welcome to the written portion of the DMV exam. \n";
cout << "You may only enter capital A, B, C, or D for your answers.\n\n" << endl;
for (int index = 0; index < SIZE; index++)
{
cout << "Enter your answer for question " << index+1 << endl;
cin >> answer[index];
while (answer[index] != 'A'
&& answer[index] != 'B'
&& answer[index] != 'C'
&& answer[index] != 'D')
{
cout << "ERROR: you must input capital A,B,C, or D" << endl;
cin >> answer[index];
}
}
test2.grade(answer);
test1.display();
system("pause");
return 0;
}
|