Converting program to use arrays

Hi,
I have a program that reads data from an input file, uses 3 nested loops, and writes the data to an output file. It stores 3 students personal info, and 5 grades for 3 different courses and calculates a final grade along with a warning or congratulations quote. It works fine but this current project wants me to read all the input data and store it into separate arrays, compute the final grade, store that in one of the arrays, and then write all of the data in the arrays to an output file in the same formatting as before. I am having major issues wrapping my head around this.
Last edited on
This is the part of my old program with the loops:

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
    //First loop for reading and printing the Student Information
	for (int a = 1; a <= studentNumber; a++)
    {
        //Reading Student information from the input file
        getline(fin,name);
        if (name.length() <= 1)                                         //Validating the name length
        {
            cout << "Student Name is incorrect.\n";
            continue;
        }
        fin >> age;
        if (age < 1 || age > 100)                                       //Validating the age
        {
            cout << "Student age is incorrect.\n";
            break;
        }
        fin.ignore ();
        getline(fin,address);
        if (address.length() <= 1)                                      //Validating the address length
        {
            cout << "Student address is incorrect.\n";
            continue;
        }
        fin >> years;
        if (years < 1 || years > 100)                                   //Validating the years
        {
            cout << "Student years is incorrect.\n";
            break;
        }
        fin.ignore ();
        getline(fin,tel);
        if (tel.length() <= 1)                                          //Validating the telephone length
        {
            cout << "Student telephone number is incorrect.\n";
            continue;
        }
        getline(fin,social);
        if (social.length() <= 1)                                       //Validating the social security number length
        {
            cout << "Student social security number is incorrect.\n";
            continue;
        }

        //Printing the data to the output file
        fout << "\t\t\t Student Grade Sheet" << endl;
        fout << setw(35) << right << "Name of Student: ";
        fout << setw(5)  << left << name << endl;
        fout << setw(35) << right << "Age: ";
        fout << setw(5)  << left << age << endl;
        fout << setw(35) << right << "Address: ";
        fout << setw(5)  << left << address << endl;
        fout << setw(35) << right << "Number of years at Texas State: ";
        fout << setw(5)  << left << years << endl;
        fout << setw(35) << right << "Telephone Number: ";
        fout << setw(5)  << left << tel << endl;
        fout << setw(35) << right << "Student Soc. Security #: ";
        fout << setw(5)  << left << social << endl << endl;

        for (int b = 1; b <=3; b++)
        {
            getline(fin,courseNum);
            if (courseNum.length() <= 1)                               //Validating the course number length
            {
                cout << "Student course number is incorrect.\n";
                continue;
            }
            fout << setw(35) << right << "Course Number: ";
            fout << setw(5)  << left << courseNum;
            {
                fin >> test1;                                   //Reading the grade for Test 1
                if (test1 < 1.00 || test1 > 100.00)            //Validating the test grade
                {
                    cout << "Test grade is incorrect.\n";
                    break;
                }
                fin >> test2;                                   //Reading the grade for Test 2
                if (test2 < 1.00 || test2 > 100.00)            //Validating the test grade
                {
                    cout << "Test grade is incorrect.\n";
                    break;
                }
                fin >> test3;                                   //Reading the grade for Test 3
                if (test3 < 1.00 || test3 > 100.00)            //Validating the test grade
                {
                    cout << "Test grade is incorrect.\n";
                    break;
                }
                fin >> test4;                                   //Reading the grade for Test 4
                if (test4 < 1.00 || test4 > 100.00)            //Validating the test grade
                {
                    cout << "Test grade is incorrect.\n";
                    break;
                }
                fin >> exam;                                    //Reading the grade for the Exam
                if (exam < 1.00 || exam > 100.00)              //Validating the test grade
                {
                    cout << "Test grade is incorrect.\n";
                    break;
                }
                fin.ignore();

                //Calculating the value of the final grade.
                finalGrade = (test1 * test1Percentage) + (test2 * test23Percentage) + (test3 * test23Percentage) + (test4 * test4Percentage) +(exam * examPercentage);

                fout << setprecision(1) << showpoint << fixed << endl;	//Formating test scores to have
                                                                        //one digit after the decimal
                fout << setw(35) << right << "Test #1: ";
                fout << setw(5)  << left << test1 << endl;
                fout << setw(35) << right << "Test #2: ";
                fout << setw(5)  << left << test2 << endl;
                fout << setw(35) << right << "Test #3: ";
                fout << setw(5)  << left << test3 << endl;
                fout << setw(35) << right << "Test #4: ";
                fout << setw(5)  << left << test4 << endl;
                fout << setw(35) << right << "Final Exam: ";
                fout << setw(5)  << left << exam << endl;
                fout << setw(35) << right << "Numerical Grade in " << courseNum << ": ";
                fout << setw(5)  << left << finalGrade << endl;

                //Determining letter grade and displaying Warning/Congratulations note
                if(finalGrade < 60)
                    {
                        grade = 'F';
                        fout << setw(35) << right << "Letter Grade in " << courseNum << ": " << setw(5) << left << grade << endl;
                        fout << setw(35) << right << "Warning Note: " << setw(48) << left << "Your grade is too low and needs improvements" << endl << endl;
                    }
                else if (finalGrade < 70)
                    {
                        grade = 'D';
                        fout << setw(35) << right << "Letter Grade in " << courseNum << ": " << setw(5) << left << grade << endl;
                        fout << setw(35) << right << "Warning Note: " << setw(48) << left << "Your grade is too low and needs improvements" << endl << endl;
                    }
                else if (finalGrade < 80)
                    {
                        grade = 'C';
                        fout << setw(35) << right << "Letter Grade in " << courseNum << ": " << setw(5) << left << grade << endl << endl;
                    }
                else if (finalGrade < 90)
                    {
                        grade = 'B';
                        fout << setw(35) << right << "Letter Grade in " << courseNum << ": " << setw(5) << left << grade << endl << endl;
                    }
                else if (finalGrade > 90 & finalGrade < 95)
                    {
                        grade = 'A';
                        fout << setw(35) << right << "Letter Grade in " << courseNum << ": " << setw(5) << left << grade << endl << endl;
                    }
                else if (finalGrade >= 95 & finalGrade <= 100)
                    {
                        grade = 'A';
                        fout << setw(35) << right << "Letter Grade in " << courseNum << ": " << setw(5) << left << grade << endl;
                        fout << setw(35) << right << "Appreciation Note: " << setw(48) << left << "Congratulations, Your performance is excellent!" << endl << endl;
                    }
                else
                fout << "Invalid Grade!" << endl;

            }
        }
    }
    //Closing input and output files
    fin.close();
    fout.close();

    //Informing the user
    cout << "Final grade has been calculated.";

	return 0;
}

This is what i have so far with my new loops using arrays:

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

for (int a = 0; a < StudentNum; a++)
    {
        for (int b = 0; b < NonNumData; b++)
        {
            getline(fin,studentStringData[a][b]);
            if (studentStringData[a][b].length() <= 1)
            {
                cout << "Student Data is incorrect.\n";
                continue;
            }
        }
        for (int c = 0; c < NumData; c++)
        {
            fin >> studentNumData[a][c];
            if (studentNumData[a][c] < 1 || studentNumData[a][c] > 100)
            {
                cout << "Student Data is incorrect.\n";
                break;
            }
        }
        for (int d = 0; d < NumCourses; d++)
        {
            for (int e = 0; e < 5; e++)
            studentGrades [a][d][5] = (studentGrades [a][d][0] * test1Percentage) + (studentGrades [a][d][1] * test23Percentage) +
                                      (studentGrades [a][d][2] * test23Percentage) + (studentGrades [a][d][3] * test4Percentage) + (studentGrades [a][d][4] * examPercentage);
            {
                fin >> studentGrades [a][d][e];
                fin.ignore();
                if (studentGrades [a][d][e] < 1 || studentGrades [a][d][e] > 100)
                {
                    cout << "Student Data is incorrect.\n";
                    break;
                }
            }

        }
I have 4 arrays, since they are all different types of data:

1
2
3
4
5

string studentStringData [StudentNum][NonNumData];
    int studentNumData [StudentNum][NumData];
    double studentGrades [StudentNum][NumCourses][NumGrades];
    char studentLetterGrades [StudentNum][NumCourses];


I just dont know how to calculate the final grade in the loop since the percentages for the different tests are all different and i need the final grade to be the 6th element of the array studentGrades

Grade Assessment Item Percentage of
Final Grade
Exam #1 (0.0 - 100.0) 10%
Exam #2 (0.0 - 100.0) 15%
Exam #3 (0.0 - 100.0) 15%
Exam #4 (0.0 - 100.0) 20%
Exam #5 (0.0 - 100.0) 40%
I feel that i might have to put my outputs inside the loops like i did before, but i am not sure how to do that since they need different headings...
this current project wants me to read all the input data and store it into separate arrays
. Also from your past post,
length,age,address,years,telephone,security number, test1 to test4,exam

Does this mean that there are several records of these data in the file?
If yes, then you can use separate arrays for each field. If you dont know how many records are in the file, think of vector.

From you last post,
1
2
3
4
5
6
7
8
9
string studentStringData [StudentNum][NonNumData];
int studentNumData [StudentNum][NumData];
double studentGrades [StudentNum][NumCourses][NumGrades];
char studentLetterGrades [StudentNum][NumCourses];

//if an array is declared "type x", then it can only hold data of "type x".
//you have the same data, "stduentNum" in "string", "int","double", and "char" arrays.
//as well as others.
//You do not need multidimentionnal arrays here. 
Hi shadowCODE, I guess i haven't been super specific, this thing is kicking my butt.
But the prof wants us to use multidimensional arrays. (some 2d, and a 3d) and i have one input file, with data for 3 students with their name, address, id number, telephone number, social, age, and years attended, and then 3 courses with 5 test grades, that looks like this:

Student Grade Sheet
John Doe
A01234567
1234 Right drive, Yellowtown, TX 73452
(281) 234 9876
123-45-6789
CS1428
CS2308
CS3002
24
1
90.9
94.2
98.5
89.8
97.7
82.1
83.5
98.2
87.4
92.1
56.3
90.3
95.3
45.7
12.1
Student Grade Sheet
Jane Smith
A09876543
123 S. Road Dr., Bluebonnet, TX 72345
(512) 546 2345
100-45-6789
CS1000
CS2000
CS4000
19
2
86.3
90.3
95.3
75.7
82.1
98.0
76.4
78.0
75.4
90.2
37.5
83.2
33.4
47.1
93.7
Student Grade Sheet
Joe Blogs
A07894561
1900 E. Parkway Dr., Austin, TX 78744
(210) 987 3242
123-45-2345
CS5000
CS6000
CS7000
21
3
80.9
90.2
98.5
89.8
97.7
99.3
100
98.2
97.4
99.1
95.4
92.1
87.4
78.6
77.5

The names you see in the [] when i declare the arrays are just named constants that hold a number ( for example, [StudentNum] is the same as [3] since i declared that StudentNum = 3 earlier on).

he wants the output file to look something like this:

Student Grade Sheet
Name of Student: John Doe
Age: 24
Address: 1234 Right drive, Yellowtown, TX 73452
Number of years at Texas State: 1
Telephone Number: (281) 234 9876
Student Soc. Security #: 123-45-6789

Course Number: CS1428
Test #1: 90.9
Test #2: 94.2
Test #3: 98.5
Test #4: 89.8
Final Exam: 97.7
Numerical Grade in CS1428: 95.0
Letter Grade in CS1428: A
Appreciation Note: Congratulations, Your performance is excellent!


Currently, i have gotten my loops this far:

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
	for (int a = 0; a < StudentNum; a++)
    {
        for (int b = 0; b < NonNumData; b++)
        {
            getline(fin,studentStringData[a][b]);
            if (studentStringData[a][b].length() <= 1)
            {
                cout << "Student Data is incorrect.\n";
                continue;
            }
            fout << studentStringData[a][b] << endl;
        }
        for (int c = 0; c < NumData; c++)
        {
            fin >> studentNumData[a][c];
            if (studentNumData[a][c] < 1 || studentNumData[a][c] > 100)
            {
                cout << "Student Data is incorrect.\n";
                break;
            }
            fout << studentNumData[a][c] << endl;
        }
        for (int d = 0; d < NumCourses; d++)
        {
            for (int e = 0; e < 5; e++)
            {
                fin >> studentGrades[a][d][e];
                fin.ignore();
                if (studentGrades[a][d][e] < 1 || studentGrades[a][d][e] > 100)
                {
                    cout << "Student Data is incorrect.\n";
                    break;
                }
                fout << studentGrades[a][d][e] << endl;
            }
            studentGrades[a][d][5] = (studentGrades [a][d][0] * test1Percentage) + (studentGrades [a][d][1] * test23Percentage) +
                                      (studentGrades [a][d][2] * test23Percentage) + (studentGrades [a][d][3] * test4Percentage) + (studentGrades [a][d][4] * examPercentage);
            fout << studentGrades[a][d][5] << endl;
        }

    }


and my output looks like this:

Student Grade Sheet
John Doe
A01234567
1234 Right drive, Yellowtown, TX 73452
(281) 234 9876
123-45-6789
CS1428
CS2308
CS3002
24
1
90.9
94.2
98.5
89.8
97.7
95.035
82.1
83.5
98.2
87.4
92.1
89.785
56.3
90.3
95.3
45.7
12.1
47.45
Student Grade Sheet
Jane Smith
A09876543
123 S. Road Dr., Bluebonnet, TX 72345
(512) 546 2345
100-45-6789
CS1000
CS2000
CS4000
19
2
86.3
90.3
95.3
75.7
82.1
84.45
98
76.4
78
75.4
90.2
84.12
37.5
83.2
33.4
47.1
93.7
68.14
Student Grade Sheet
Joe Blogs
A07894561
1900 E. Parkway Dr., Austin, TX 78744
(210) 987 3242
123-45-2345
CS5000
CS6000
CS7000
21
3
80.9
90.2
98.5
89.8
97.7
93.435
99.3
100
98.2
97.4
99.1
98.78
95.4
92.1
87.4
78.6
77.5
83.185



So I am getting all the right data in my arrays, and it is calculating the grade correctly, but i dont know how to output it correctly since i cannot assign the array data to separate variables like i did in the previous project.
So i am getting closer. I currently have the following and it output everything in the correct format except for the studentStringData, and the studentNumData. I put the courses into their own array since i could loop the course number output, and i looped the exam output, numerical grade output, and letter grade output.

The issue now is i dont know how to loop all of the string data and the num data inot the output since they all need different "headings"

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

for (int a = 0; a < StudentNum; a++)
    {
        for (int b = 0; b < NonNumData; b++)
        {
            getline(fin,studentStringData[a][b]);
            if (studentStringData[a][b].length() <= 1)
            {
                cout << "Student Data is incorrect.\n";
                continue;
            }
            fout << studentStringData[a][b] << endl;
        }
        for (int c = 0; c < NumData; c++)
        {
            fin >> studentNumData[a][c];
            fin.ignore();
            if (studentNumData[a][c] < 1 || studentNumData[a][c] > 100)
            {
                cout << "Student Data is incorrect.\n";
                break;
            }
            fout << studentNumData[a][c] << endl;
        }
        for (int d = 0; d < NumCourses; d++)
        {
            getline(fin,studentCourses[a][d]);
            if (studentCourses[a][d].length() <= 1)
            {
                cout << "Student Data is incorrect.\n";
                continue;
            }
            fout << setw(35) << right << "Course Number: " << setw(5) << left << studentCourses[a][d] << endl;
            for (int e = 0; e < 5; e++)
            {
                fin >> studentGrades[a][d][e];
                fin.ignore();
                if (studentGrades[a][d][e] < 1 || studentGrades[a][d][e] > 100)
                {
                    cout << "Student Data is incorrect.\n";
                    break;
                }
                fout << setw(40) << right << "Exam #" << (e + 1) << ": " << setw(5) << left << studentGrades[a][d][e] << endl;
            }
            studentGrades[a][d][5] = (studentGrades [a][d][0] * test1Percentage) + (studentGrades [a][d][1] * test23Percentage) +
                                      (studentGrades [a][d][2] * test23Percentage) + (studentGrades [a][d][3] * test4Percentage) + (studentGrades [a][d][4] * examPercentage);
            fout << setprecision(2) << showpoint << fixed;
            fout << setw(35) << right << "Numerical Grade in " << studentCourses [a][d] << ": " << setw(5) << left << studentGrades[a][d][5] << endl;
            if(studentGrades[a][d][5] < 60)
                    {
                        studentLetterGrades[a][d] = 'F';
                        fout << setw(35) << right << "Letter Grade in " << studentCourses [a][d] << ": " << setw(5) << left << studentLetterGrades[a][d] << endl;
                        fout << setw(40) << right << "Warning Note: " << setw(48) << left << "Your grade is too low and needs improvements" << endl << endl;
                    }
                else if (studentGrades[a][d][5] < 70)
                    {
                        studentLetterGrades[a][d] = 'D';
                        fout << setw(35) << right << "Letter Grade in " << studentCourses [a][d] << ": " << setw(5) << left << studentLetterGrades[a][d] << endl;
                        fout << setw(35) << right << "Warning Note: " << setw(48) << left << "Your grade is too low and needs improvements" << endl << endl;
                    }
                else if (studentGrades[a][d][5] < 80)
                    {
                        studentLetterGrades[a][d] = 'C';
                        fout << setw(35) << right << "Letter Grade in " << studentCourses [a][d] << ": " << setw(5) << left << studentLetterGrades[a][d] << endl << endl;
                    }
                else if (studentGrades[a][d][5] < 90)
                    {
                        studentLetterGrades[a][d] = 'B';
                        fout << setw(35) << right << "Letter Grade in " << studentCourses [a][d] << ": " << setw(5) << left << studentLetterGrades[a][d] << endl << endl;
                    }
                else if (studentGrades[a][d][5] > 90 & studentGrades[a][d][5] < 95)
                    {
                        studentLetterGrades[a][d] = 'A';
                        fout << setw(35) << right << "Letter Grade in " << studentCourses [a][d] << ": " << setw(5) << left << studentLetterGrades[a][d] << endl << endl;
                    }
                else if (studentGrades[a][d][5] >= 95 & studentGrades[a][d][5] <= 100)
                    {
                        studentLetterGrades[a][d] = 'A';
                        fout << setw(35) << right << "Letter Grade in " << studentCourses [a][d] << ": " << setw(5) << left << studentLetterGrades[a][d] << endl;
                        fout << setw(40) << right << "Appreciation Note: " << setw(48) << left << "Congratulations, Your performance is excellent!" << endl << endl;
                    }
                else
                fout << "Invalid Grade!" << endl;
        }

    }
    //Closing input and output files
    fin.close();
    fout.close();

    //Informing the user
    cout << "Final grade has been calculated.";

	return 0;
}



that above gives me this output:

Student Grade Sheet
John Doe
A01234567
1234 Right drive, Yellowtown, TX 73452
(281) 234 9876
123-45-6789
24
1
Course Number: CS1428
Exam #1: 90.9
Exam #2: 94.2
Exam #3: 98.5
Exam #4: 89.8
Exam #5: 97.7
Numerical Grade in CS1428: 95.04
Letter Grade in CS1428: A
Appreciation Note: Congratulations, Your performance is excellent!

Course Number: CS2308
Exam #1: 82.10
Exam #2: 83.50
Exam #3: 98.20
Exam #4: 87.40
Exam #5: 92.10
Numerical Grade in CS2308: 89.78
Letter Grade in CS2308: B

Course Number: CS3002
Exam #1: 56.30
Exam #2: 90.30
Exam #3: 95.30
Exam #4: 45.70
Exam #5: 12.10
Numerical Grade in CS3002: 47.45
Letter Grade in CS3002: F
Warning Note: Your grade is too low and needs improvements

Student Grade Sheet
Jane Smith
A09876543
123 S. Road Dr., Bluebonnet, TX 72345
(512) 546 2345
100-45-6789
19
2
Course Number: CS1000
Exam #1: 86.30
Exam #2: 90.30
Exam #3: 95.30
Exam #4: 75.70
Exam #5: 82.10
Numerical Grade in CS1000: 84.45
Letter Grade in CS1000: B

Course Number: CS2000
Exam #1: 98.00
Exam #2: 76.40
Exam #3: 78.00
Exam #4: 75.40
Exam #5: 90.20
Numerical Grade in CS2000: 84.12
Letter Grade in CS2000: B

Course Number: CS4000
Exam #1: 37.50
Exam #2: 83.20
Exam #3: 33.40
Exam #4: 47.10
Exam #5: 93.70
Numerical Grade in CS4000: 68.14
Letter Grade in CS4000: D
Warning Note: Your grade is too low and needs improvements

Student Grade Sheet
Joe Blogs
A07894561
1900 E. Parkway Dr., Austin, TX 78744
(210) 987 3242
123-45-2345
21
3
Course Number: CS5000
Exam #1: 80.90
Exam #2: 90.20
Exam #3: 98.50
Exam #4: 89.80
Exam #5: 97.70
Numerical Grade in CS5000: 93.44
Letter Grade in CS5000: A

Course Number: CS6000
Exam #1: 99.30
Exam #2: 100.00
Exam #3: 98.20
Exam #4: 97.40
Exam #5: 99.10
Numerical Grade in CS6000: 98.78
Letter Grade in CS6000: A
Appreciation Note: Congratulations, Your performance is excellent!

Course Number: CS7000
Exam #1: 95.40
Exam #2: 92.10
Exam #3: 87.40
Exam #4: 78.60
Exam #5: 77.50
Numerical Grade in CS7000: 83.19
Letter Grade in CS7000: B

That above is very close, but i need this:


Student Grade Sheet
Name of Student: John Doe
Student ID: A01234567
Address: 1234 Right drive, Yellowtown, TX 73452
Telephone Number: (281) 234 9876
Student Soc. Security #: 123-45-6789
Age: 24
Number of years at Texas State: 1

Course Number: CS1428
Exam #1: 90.9
Exam #2: 94.2
Exam #3: 98.5
Exam #4: 89.8
Exam #5: 97.7
Numerical Grade in CS1428: 95.04
Letter Grade in CS1428: A
Appreciation Note: Congratulations, Your performance is excellent!


Where the first 6 lines of data (which changes for each student) is in the string studentStringData array, and the Age, and Years attended are in the int studentNumData array

Well, i just decided that it wasn't possible and did it this way to get the correct output:

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

for (int a = 0; a < StudentNum; a++)
    {
        for (int b = 0; b < NonNumData; b++)
        {
            getline(fin,studentStringData[a][b]);
            if (studentStringData[a][b].length() <= 1)
            {
                cout << "Student Data is incorrect.\n";
                continue;
            }
        }
        fout << "\t\t\t " << studentStringData[a][0] << endl;
        fout << setw(35) << right << "Name of Student: ";
        fout << setw(30)  << left << studentStringData[a][1] << endl;
        fout << setw(35) << right << "Student ID: ";
        fout << setw(30)  << left << studentStringData[a][2] << endl;
        fout << setw(35) << right << "Address: ";
        fout << setw(30)  << left << studentStringData[a][3] << endl;
        fout << setw(35) << right << "Telephone Number: ";
        fout << setw(30)  << left << studentStringData[a][4] << endl;
        fout << setw(35) << right << "Student Soc. Security #: ";
        fout << setw(30)  << left << studentStringData[a][5] << endl;

        for (int c = 0; c < NumData; c++)
        {
            fin >> studentNumData[a][c];
            fin.ignore();
            if (studentNumData[a][c] < 1 || studentNumData[a][c] > 100)
            {
                cout << "Student Data is incorrect.\n";
                break;
            }
        }
        fout << setw(35) << right << "Age: ";
        fout << setw(30)  << left << studentNumData[a][0] << endl;
        fout << setw(35) << right << "Number of years at Texas State: ";
        fout << setw(30)  << left << studentNumData[a][1] << endl << endl;

        for (int d = 0; d < NumCourses; d++)
        {
            getline(fin,studentCourses[a][d]);
            if (studentCourses[a][d].length() <= 1)
            {
                cout << "Student Data is incorrect.\n";
                continue;
            }
            fout << setw(35) << right << "Course Number: ";
            fout << setw(30)  << left  << studentCourses[a][d] << endl;
            for (int e = 0; e < 5; e++)
            {
                fin >> studentGrades[a][d][e];
                fin.ignore();
                if (studentGrades[a][d][e] < 1 || studentGrades[a][d][e] > 100)
                {
                    cout << "Student Data is incorrect.\n";
                    break;
                }
                fout << setw(35) << right << "Exam #" << (e + 1) << ": ";
                fout << setw(30)  << left  << studentGrades[a][d][e] << endl;
            }
            studentGrades[a][d][5] = (studentGrades [a][d][0] * test1Percentage) + (studentGrades [a][d][1] * test23Percentage) +
                                      (studentGrades [a][d][2] * test23Percentage) + (studentGrades [a][d][3] * test4Percentage) + (studentGrades [a][d][4] * examPercentage);
            fout << setprecision(2) << showpoint << fixed;
            fout << setw(35) << right << "Numerical Grade in " << studentCourses [a][d] << ": ";
            fout << setw(30)  << left  << studentGrades[a][d][5] << endl;
            if(studentGrades[a][d][5] < 60)
                    {
                        studentLetterGrades[a][d] = 'F';
                        fout << setw(35) << right << "Letter Grade in " << studentCourses [a][d] << ": ";
                        fout << setw(30)  << left << studentLetterGrades[a][d] << endl;
                        fout << setw(35) << right << "Warning Note: ";
                        fout << setw(30)  << left << "Your grade is too low and needs improvements" << endl << endl;
                    }
                else if (studentGrades[a][d][5] < 70)
                    {
                        studentLetterGrades[a][d] = 'D';
                        fout << setw(35) << right << "Letter Grade in " << studentCourses [a][d] << ": ";
                        fout << setw(30)  << left << studentLetterGrades[a][d] << endl;
                        fout << setw(35) << right << "Warning Note: ";
                        fout << setw(30)  << left  << "Your grade is too low and needs improvements" << endl << endl;
                    }
                else if (studentGrades[a][d][5] < 80)
                    {
                        studentLetterGrades[a][d] = 'C';
                        fout << setw(35) << right << "Letter Grade in " << studentCourses [a][d] << ": ";
                        fout << setw(30)  << left  << studentLetterGrades[a][d] << endl << endl;
                    }
                else if (studentGrades[a][d][5] < 90)
                    {
                        studentLetterGrades[a][d] = 'B';
                        fout << setw(35) << right << "Letter Grade in " << studentCourses [a][d] << ": ";
                        fout << setw(30)  << left  << studentLetterGrades[a][d] << endl << endl;
                    }
                else if (studentGrades[a][d][5] > 90 & studentGrades[a][d][5] < 95)
                    {
                        studentLetterGrades[a][d] = 'A';
                        fout << setw(35) << right << "Letter Grade in " << studentCourses [a][d] << ": ";
                        fout << setw(30)  << left  << studentLetterGrades[a][d] << endl << endl;
                    }
                else if (studentGrades[a][d][5] >= 95 & studentGrades[a][d][5] <= 100)
                    {
                        studentLetterGrades[a][d] = 'A';
                        fout << setw(35) << right << "Letter Grade in " << studentCourses [a][d] << ": ";
                        fout << setw(30)  << left  << studentLetterGrades[a][d] << endl;
                        fout << setw(35) << right << "Appreciation Note: ";
                        fout << setw(30)  << left  << "Congratulations, Your performance is excellent!" << endl << endl;
                    }
                else
                fout << "Invalid Grade!" << endl;
        }

    }
    //Closing input and output files
    fin.close();
    fout.close();

    //Informing the user
    cout << "Final grade has been calculated.";

	return 0;
}


Topic archived. No new replies allowed.