Is this a scope issue?

ive got my program working, not exactly how I want it to, but it works. for my final assignment, I have to read from a file and write the info to a structure. I figured I would write the data to arrays (for the different value types) and then build the structure from the arrays. I am having an issue with making sure that the array is built properly. As you will notice, I have added a cout at the end of main to test for values in the array. Why is it that I cant cout the proper values from the array at the end of main? It prints out the proper values during the loop so I'm guessing its the placement of my last cout statement but I cant quite nail it down. I have tried adding it to everywhere I can think of but still not working. Is there a different way to test the values of the array? Am I just doing it all wrong?
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
//
//  main.cpp
//  GradeCalculator
//
//  Created by Andrew  on 6/4/13.
//
//

#include <iostream>
#include <fstream>
#include <string>
#include "Assignment4.h"

using namespace std;


//----------function declarations
void GetInFileName(string&);
void GetOutFileName(string&);
int ReadFile(double&);
string GetComment(char&);
void GetLetterGrade(double&);
int OpenInFile(ifstream&);
int OpenOutFile(ofstream&);
//string GetOutFileName(string&);
int WriteData(char&, string&);
int CalculateGrade();

//-----------Main Body
int main()
{
    double TotalGPA;
    ifstream InDataFile;
    ofstream OutDataFile;
    string InFileName;
    string OutFileName;
    string Quote;
    //char LetterGrade;
    cout << "Welcome to the GradeCaculator Deluxe." << endl;
    ReadFile(TotalGPA);
    GetLetterGrade(TotalGPA);//this function calls "GetComment()"
    //WriteData(LetterGrade, Quote);
    //---------create structure--------------------
    struct Grades
    {
        string StudentName;
        int NoOfHomeWorkGrades;
        double HomeworkGPA;
        double HomeworkWeight;
        int NoOfProjectGrades;
        double ProjectGPA;
        double ProjectWeight;
        int NoOfExamGrades;
        double ExamWeight;
        double ExamGPA;
        double TotalGPA;
        char LetterGrade;
        string Comment;
    };
    //system ("pause");
    return 0;
}//end main
//-----------GetFileName
//-----------Get file name to read from
void GetInFileName(string& InFileName)
{
    cout << "Enter the name of the file to gather info from (including extension): ";
    cin >> InFileName;
    //reference variables do not need a return
}//end GetInFileName
//----------GetOutFileName
//----------Get name of output file
void GetOutFileName(string& OutFileName)
{
    cout << "Enter the name of the file to write info to (including extension): ";
    cin >> OutFileName;
}//end GetOutFileName
//----------OpenInFile
//----------open the user specified file to read from
int OpenInFile(ifstream& InDataFile)
{
    string InFileName;
    GetInFileName(InFileName);
    
    InDataFile.open(InFileName.c_str());
    
    if (!InDataFile)
    {
        cout << "File Failed to open...Program terminated" << endl;
        return 1;
    }//end if
    //ReadFile(TotalGPA);
    return 0;
    
}//end OpenInFile
int OpenOutFile(ofstream& OutDataFile)
{
    string OutFileName;
    GetOutFileName(OutFileName);
    
    OutDataFile.open(OutFileName.c_str());
    
    if (!OutDataFile)
    {
        cout << "File Failed to open...Program terminated" << endl;
        return 1;
    }//end if
    //ReadFile(TotalGPA);
    return 0;
}//end OpenInFile

//---------ReadFile
//---------read the user specified file
int ReadFile (double& TotalGPA)
{
    ifstream InDataFile;
    int RowNumber;
    int NoOfAssignments;
    float TotalPtsAllowed;
    int index;
    float TotalScore;
    int Grades;
    double Weight;
    double Average;
    int Assignments[3];
    //int GradeArray[50];
    //double WeightArray[3];
    
    OpenInFile(InDataFile);
    
    RowNumber = 0;
    while (RowNumber < 3)
    {//start outter loop
        InDataFile >> NoOfAssignments >> TotalPtsAllowed;
        index = 0;
        TotalScore = 0;
         Assignments[index] = NoOfAssignments;
        cout << Assignments[index] << endl;
        
        while(index < NoOfAssignments)
        {//start (inner loop)
            InDataFile >> Grades;
            //Assignments[index] = NoOfAssignments;
            index++;
            
            TotalScore = TotalScore + Grades;
             }//end while (inner loop)
        InDataFile >> Weight;
        cout << TotalScore << "    " << TotalPtsAllowed << endl;
        Average = TotalScore / TotalPtsAllowed;
        //Average = (TotalScore / TotalPtsAllowed) * Weight;
        TotalGPA = TotalGPA + Average;
        RowNumber++;
     
    }//end while (outer loop)
    cout << "Total GPA is:: " << TotalGPA << endl;
    cout << Assignments[index] << endl;
    return 0;
   
}//end ReadFile
//-----------WriteData
//-----------write the data to user specified file
int WriteData (char& LeterGrade, string& Quote)
{
    //char LetterGrade;
    //string Quote;
    ofstream OutDataFile;
    
    OpenOutFile(OutDataFile);
    OutDataFile << "NAME: A.C. Millard" << endl;
    OutDataFile << "Your Letter Grade is ::" << LeterGrade << endl;
    OutDataFile << Quote << endl;
    return 0;
}//end WrtieData
//----------GetComment
//----------Create witty comment based on the letter grade
string GetComment (char& LetterGrade)
{
    //char LetterGrade;
    //LetterGrade=GetLetterGrade();
    string Quote;
    //cout << LetterGrade << endl;
    switch(LetterGrade)
    {
        case 'A' : Quote = "The Fonz says...Exactamundo!";
            break;
        case 'B' : Quote = "The Fonz says..Aaaaeeeyyy!";
            break;
        case 'C' : Quote = "The Fonz says he was wrrroooogh about you.";
            break;
        case 'D' : Quote = "The Fonz says...Step into my office.";
            break;
        case 'F' : Quote = "The Fonz says Whoa!";
            break;
    }
    cout << Quote << endl;
    WriteData(LetterGrade, Quote);
    return Quote;
}//end GetComment
//---------GetLetterGrade
//---------Get the letter grade based on the average
void GetLetterGrade(double& TotalGPA)
{
    //cout << TotalGPA << endl;
    //double TotalGPA;
    char LetterGrade;
    
    if  (TotalGPA > 3.50)
        LetterGrade = 'A';
    else
    {
        if (TotalGPA >= 2.40 && TotalGPA < 3.50)
            LetterGrade = 'B';
        if (TotalGPA >= 1.40 && TotalGPA < 2.40)
            LetterGrade = 'C';
        if (TotalGPA >= 0.040 && TotalGPA < 1.40)
            LetterGrade = 'D';
        if (TotalGPA < .40)
            LetterGrade = 'F';
    }//end else
    cout << "Your Letter Grade is:: " << LetterGrade << endl;
    GetComment(LetterGrade);
    //return LetterGrade;
}//end GetLetterGrade

//----------CalculateGrade
//----------perform Grade Calcualtions
int CalculateGrade()
{
    int Weight;
    int Grade;
    int TotalScore;
    int  TotalPtsAllowed;
    Grade=(TotalScore / TotalPtsAllowed) * Weight;
    return Grade;
}


This is what my text file looks:
6 87 88 89 90 91 92 0.70
4 95 96 97 98 0.20
3 100 100 100 0.10
Is there anybody that can help me with this?
Topic archived. No new replies allowed.