I need some help..here is what i am trying to make and here is the code
One of your professors has asked you to write a program to grade her final exams. which consist of only 20 multiple-choice questions. Each question has one of four possible answers: A, B, C, or D. The file CorrectAnswers.txt, which is on the Student CD, contains the correct answers for all of the questions, each answer is written on a separate line. The first line contains the answer to the first question, the second line contains the answer to the second question, and so forth.
Write a program that reads the contents of the CorrectAnswers.txt file into a one-dimensional char array, and then reads the contents of another file, containing a student's answers, into a second charr array. The Student CD has a file named StudentAnswer.txt that you can use for testing purposes. The program should determine the number of questions that the student missed, and then display the following:
* A list of the questions missed by the student, showing the correct answer and the incorrect answer
provided by the student for each missed question.
* The total number of questions missed
* The percentage of questions answered correctly. This can be calculated as:
Correctly Answered Questions (divided by) Total Number of Questions
*If the percentage of correctly answered questions is 70% or greater, the program should indicate that the student passed the exam. Otherwise, it should indicate that the student failed the exam.
Code:#include <iostream> #include <fstream> using namespace std; int main () { const int numOfAnswers= 20; const int stringSize=1; char correctAnswers[numOfAnswers][stringSize]; char studentAnswers[numOfAnswers][stringSize]; int totalMissed=0; ifstream inputFile; //Open the file StudentAnswers. inputFile.open("CorrectAnswers.txt"); //Read the 20 answers from the file CorrectAnswers into the char array correctAnswers. for (int count=0; count < numOfAnswers; count++) { inputFile>> correctAnswers[count][stringSize]; } //close the file. inputFile.close(); //Open the file StudentAnswers. inputFile.open("StudentAnswers.txt"); //Read the 20 answers from the file StudentAnswers into the char array studentAnswers. for (int count=0; count < numOfAnswers; count++) { inputFile>> studentAnswers[count][stringSize]; } //close the file. inputFile.close(); return 0; } for(x = 0; x < 20; x++) if(correct[x] != answer[x]) wrong[x]=false; for(x = 0; x < 20; x++) { if(!wrong[x]) { cout<<x<<". wrong"<<endl; total++; } else cout<<x<<". right"<<endl; } cout<<total<<"wrong, "<<(20-total)<<"right"<<endl;
I do not know what is wrong with it!