Need help with assignment please!

Hello! I'm having trouble with an assignment for class and would greatly appreciate help!
Here is the assignment:

The history teacher at your school needs help in grading a True/False test. The students' IDs and test answers are stored in a file. The first entry in the file contains answers to the test in the form:

TFFTFFTTTTFFTFTFTFTT

Every other entry in the file is the student ID, followed by a blank, followed by the student's responses. For example, the entry...

ABC54301 TFTFTFTT TFTFTFFTTFT

indicates that the student ID is ABC54301 and the answer to question 1 is True, the answer to question 2 is False, and so on. This student did not answer question 9. The exam has 20 questions, and the class has more than 150 students. Each correct answer is awarded two points, each wrong answer gets one point deducted, and no answer gets zero points. Write a program that processes the test data. The output should be the student's ID, followed by the answers, followed by the test score, followed by the test grade.
Assume the following grade scale: 90%-100%, A; 80%-89.99%, B; 70%-79.99%, C; 60%-69.99%, D; 0%-59.99%, F.
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
  #include <iostream>
#include <fstream>
#include <string>
#include <stdlib.h>

using namespace std;

int main()
{
    string id;
    char answers [20];
    char studentID [9];
    char response;
    char fileName [25];
    int testScore;
    
    cout << "\nThis program will take the teacher's correct test answers";
    cout << "\nAs well as the 150 students answers, and grade the tests.\n" << endl;
    
    cout << "Enter the input file name: ";
    cin >> fileName;
    
    ifstream inFile;
    inFile.open (fileName);
    
    ofstream outFile;
    outFile.open ("output.txt");
    
    cout << "\nStudent IDs     |     Answers |  % |  Grades";
    cout << "\n--------------------------------------------";
    cout << studentID << answers << endl;
    
    
    for (int i=0; i<20; i++)
        inFile >> answers [i];
    
    while ( ( inFile >> id))
    {
        cout << "\n" << id << " ";
        inFile.get(response);
        testScore = 0;
        
        for (int i = 0; i < 20; i++)
        {
            inFile.get (response);
            
            cout << " " << response;
            
            if (response == ' ')
                testScore += 0;
            else
                if (response == answers [i])
                    testScore += 2;
                else
                    testScore += -1;
        }
        
        cout << "   " << testScore << "  ";
        
        double p = testScore * 2.5;
        
        if (p >= 90)
            cout << 'A';
        else
            if (p >=80)
                cout << 'B';
            else
                if (p >=70)
                    cout << 'C';
                else
                    if (p >=60)
                        cout << 'D';
                    else
                        cout << 'F';
    }
    
    inFile.close();
    outFile.close();
    return 0;
}
You don't happen to know this guy ? :)
http://www.cplusplus.com/forum/beginner/172173/

What exactly is your question?
EDIT: You didn't write the code, it already exists online.
Last edited on
Haha their is chance we could be in the same class but i doubt it. Researching it seems this has been used my professors for years. I completely forgot to put down my issue!

What I am having trouble with is when I run the program and type in the inout file it doesn't display results. Any idea what I am doing wrong?
Yeah, there's a fantastic chance we're in the same class, as we're doing the same program with the same due date. :P

CSC 102 with the Chinese guy?
Topic archived. No new replies allowed.