[HELP] On my school assignment

Im completely lost on how to even start this assignment. If someone could give me a push start in the right direction it would be awesome.

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
94
95

//  Homework Assignment #5
//  Exam Grader
#include <iostream>
#include <iomanip>
#include <fstream>
using namespace std;

// Function prototypes
void readFile(char[], char[], int);
void compareAnswers(char[], char[], int, int &);
void displayTestResults(int, int);

int main()
{
   // Constant for the number of questions
   const int NUM_QUESTIONS = 20;
   
   // Number of questions missed.
   int numMissed;
   
   // Array to hold the correct answers
   char correct[NUM_QUESTIONS];
   
   // Array to hold the student's answers
   char student[NUM_QUESTIONS];
   
   // Read the correct answers.
   readFile("CorrectAnswers.txt", correct, NUM_QUESTIONS);
   
   // Read the student's answers.
   readFile("StudentAnswers.txt", student, NUM_QUESTIONS);
   
   // Compare the student's answers with the correct
   // answers.
   compareAnswers(student, correct, NUM_QUESTIONS, numMissed);
   
   // Display the test results.
   displayTestResults(numMissed, NUM_QUESTIONS);
   
   cout << "Press ENTER to close\n";
   cin.ignore();
   return 0;
}

//********************************************************
// The readFile function reads the contents of           *
// an answer file into an array.                         *
//********************************************************

void readFile(char filename[], char array[], int size)
{
   // Loop counter
   int count = 0;
   
   // File stream object.
   ifstream inFile;
   
   // Open the file.
   inFile.open(filename);
   
   // Read the contents of the file into the array.
   while (count < size && inFile >> array[count])
   {
        cout << filename;
      // Increment the counter.
      count++;
   }
   
   // Close the file.
   inFile.close();
}

//********************************************************
// The compareAnswers function compares the elements of  *
// the student array with the elements of the correct    *
// array. For each correct answer, a 'C' is stored in    *
// the results array. For each incorrect answer, an 'I'  *
// is stored in the results array.                       *
//********************************************************

void compareAnswers(char student[], char correct[],
                    int size, int &numMissed)
{
 
}

//********************************************************
// displayTestResults displays the test statistics.      *
//********************************************************

void displayTestResults(int numMissed, int numQuestions)
{
   
}


Learning Outcome #3: Implement array structures to best organize and process the user’s
data.
You have been asked to finish the coding for a C++ program that grades the final exam for
a college professor. The exam consists of 20 multiple choice questions (easy final exam!).
The possible correct answers for each M/C question are A, B, C or D. Within this assignment
file, you will find a file called, CorrectAnswers.txt, which contains the correct answers to the
final exam. Go ahead and look at how the file is organized – each correct answer is printed
on a separate line. You have also been supplied with a text file, StudentAnswers.txt, that
contains the answers for a student who took the exam. You’ll see that the student answer
file is formatted similar to the answer key (CorrectAnswers.txt).
You have also been supplied with the code, HW_5.cpp, which is a partially coded C++
program to accomplish the following tasks:
  1. Grade the student’s test by comparing the answer key (CorrectAnswers.txt) with the
student’s responses (StudentAnswers.txt)
  2. As your code “grades” the student’s answers, for each incorrect student response,
display: 1) the question number that has been missed; 2) the student’s answer; and 3) the
correct answer.
o For example:
􀂃 Question 1 is incorrect
􀂃 Student answer: B
􀂃 Correct answer: A
  3. summarize the student’s effort by displaying the total number of questions missed and
the percentage of questions answered correctly. Formatting requirement: The percentage
should be displayed in the format, for example, 81.0% - keep one digit after the decimal
point.
  4. if the student correctly answered 70% or more – print out a statement indicating that
the student passed the final exam; otherwise, indicating the student failed the exam.
Additionally, within the .cpp file, comment how/where you would change the code to
process a class of 50 students (2 points).
NOTES:
o Place your name in the initial documentation of the .cpp file. This is a must in the
requirement of good documentation style.
o You may add to the program (additional screens, etc.) as long as the user (me!)
knows how to interact with your program.
o No input validation is needed – the files that have been supplied have already
screened the input data.
o I’ve supplied sample prototypes, calls and headers – if you want to create the
needed functions using a different interface – that’s fine – as long as it’s efficient.
o Remember to copy the answer key files into the same directory as your .cpp file
before you compile and run your program.
For the function compareAnswers you're going to need a loop (I would say the 'For' loop, but it looks like you've only gone through the 'While' loop), an if statement and use of the equality operator '=='. Try to figuring it out from there and post again if you need clarification or help.
Ok, thanks for the start.
Topic archived. No new replies allowed.