question archive I have a lot of errors in the beginning and don't know how to end the code, so I really need help coding this assignment
Subject:Computer SciencePrice: Bought3
I have a lot of errors in the beginning and don't know how to end the code, so I really need help coding this assignment.
Here are the instructions:
One of your professors has asked you to code 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 contains the correct answers for all of the questions, with each answer 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.
Code a program that reads the contents of the correctAnswers.txt
Both files are included in the repo when you clone it from GitHub.
The output should look something like this:
Checking the answers...
Missed question #4. Students answer: D Correct answer: C
Missed question #12. Students answer: A Correct answer: D
Missed question #17. Students answer: C Correct answer: D
Number of correct answers: 17
Percentage answered correctly: 85.00%
The student passed the exam.
Heres what I have coded:
#include <iostream>
#include <fstream>
void getCorrectAnswers(char[], int);
void getStudentAnswers(char[], int);
void compareAnswers(char[], int);
void testGrade(float[], int);
int main()
}
cout<<"This program will read the correct test answers and the student answers.n";
cout << "First we will read the correct answers into the program...n";
getCorrectAnswers;
cout << "Now reading the students answer file...n";
getStudentAnswers;
cout << "Going to now show the missed questions with the correct answers.n";
compareAnswers;
testGrade;
system("pause");
return 0;
}
//function reads the correct answer key
void getCorrectAnswers(char[], int)
{
const int ARRAY_SIZE = 20;
int correctAnswers[ARRAY_SIZE];
int count; // loop
ifstream inputFile; // input file stream object
inputFile.open("C:\Users\sixcore\Documents\Visual Studio 2010\Projects\exam_grader\CorrectAnswers.txt");
//read correct answers
for (count = 0; count < ARRAY_SIZE; count++)
inputFile >> correctAnswers[count];
//close file
inputFile.close();
return correctAnswers;
}
//function read the student answers
void getStudentAnswers(char[], int)
{
//array reads the students answers to the array
const int ARRAY_SIZE = 20;
int studentAnswers[ARRAY_SIZE];
int count;
ifstream inputFile;
inputFile.open("C:\Users\sixcore\Documents\Visual Studio 2010\Projects\exam_grader\StudentAnswers.txt");
for (count = 0; count < ARRAY_SIZE; count++)
inputFile >> studentAnswers[count];
//close file
inputFile.close();
return studentAnswers;
}
//compares the correct answers to the student answers
void compareQuestions(char[], int)
{
const char SIZE = 1;
char correctAnswers;
char studentAnswers;
char CompareAnswers;
bool arrayEqual = true;
int count = 0;
// compare student answers to the correct answers
while (arraysEqual && count < SIZE)
{
if (correctAnswers[count] != studentAnswers[count])
arraysEqual = false;
cout ++;
}
if(arraysEqual)
cout << "The Correct Answers compares to the student answers,n" << compareAnswers << endl;
else
return;
}
//function grades the test answers
void testGrade(float[], int)
{
int grade;
cout << "Going to show the grade if it is higher than 70%.n";
if (grade >= 70)
cout << "The student has passed.n";
else
cout << "The student did not pass.n";
}