// Author: Brandon Mohawk // Teacher: Dr. Wang // Due Date: 02/12/07 // // File: examgrader.cpp // Compile: g++ examgrader.cpp -o examgrader.out // Run: ./examgrader.cpp // // Goal: The program will read two text files consisting // of a list of answers, CorrectAnswers.txt being the // the correct answers, and StudentAnswers.txt being the // student's answers. The program then displays how many // questions the student got wrong, which questions he got // wrong and his answer, what % of the questions he got // correct, and whether or not he passed the exam. #include #include using namespace std; const int M = 20; ifstream inStud, inCor; void compareTo(char[], char[]); int main() { system("clear"); char correct[M], student[M]; inStud.open("StudentAnswers.txt"); inCor.open("CorrectAnswers.txt"); if (!inStud) { cout << "StudentAnswers.txt was not found.\n"; exit(0); } for (int i=0; i> student[i]; if (!inCor) { cout << "CorrectAnswers.txt was not found.\n"; exit(0); } for (int i=0; i> correct[i]; compareTo(correct, student); return 0; } void compareTo(char correct[], char student[]) { cout << "The student missed the following questions:\n\n"; int num = 0; for (int i=0; i= 70) cout << "The student passed the exam!\n\n"; else cout << "The student failed the exam.\n\n"; }