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
|
#include <fstream>
using namespace std;
char answer[20];
char student[20];
char id[8];
int tGrade[150];
char lGrade [150];
void aEntry(char answer[]);
void sEntry (char id[], char student[]);
void sEval (char student[], char answer[]);
void print (char id[], char student[], int tGrade[], char grade[]);
int main()
{
aEntry (answer);
sEntry (id, student);
sEval (student, answer);
print(id, student, tGrade, lGrade);
}
void aEntry(char answer[])
{
ifstream in;
ofstream out;
int i;
for (i=1; i < 21; i++) //May be modified
{
in >> answer[i];
out << endl;
}
}
void sEntry (string id, char student[])
{
ifstream in;
ofstream out;
int i;
for (i=0; i < 150; i++)
{
in >> id;
in.ignore (1,'A');
in >> student;
}
}
void sEval(char student[], char answer[])
{
int points;
int i;
for (i=0; i < 150; i++)
{
for (i=0; i <20; i++)
{
if (answer[i] == student[i])
points += 2;
else if (answer[i] != student[i])
points -= 1;
else if (student[i] == ' ')
continue;
}
tGrade[i] = points / 40;
}
for (i=0; i < 150; i++)
{
if (tGrade[i] <= 100 && tGrade[i] >= 90)
lGrade[i] == 'A';
if (tGrade[i] <= 89.99 && tGrade[i] >= 80)
lGrade[i] == 'B';
if (tGrade[i] <= 79.99 && tGrade[i] >= 70)
lGrade[i] == 'C';
if (tGrade[i] <= 69.99 && tGrade[i] >= 60)
lGrade[i] == 'D';
if (tGrade[i] <= 59.99 )
lGrade[i] == 'F';
}
}
void print (string id, char student[], int tGrade, char grade)
{
ifstream in;
ofstream out;
int i;
for (int i=0; i < 150; i++)
{
out << id[i] << " "<< student[i]<< " ";
out << tGrade[i]<< "%" < lGrade[i];
}
}
| |