Compiles but refuses to print out char Grades ???

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
#include <fstream>
#include <ostream>
#include <iostream>
#include <iomanip>

using namespace std;

const int NAMESIZE = 15;
const int MAXRECORDS = 50;
struct Grades              // declares a structure
{
	char name[NAMESIZE + 1];
	float test1;
	float test2;
	float final;
	
	char findLetterGrade;
	
};

typedef Grades gradeType[MAXRECORDS];    
 // This makes gradeType a data type
 // that holds MAXRECORDS
 // Grades structures.


void readIt(ifstream&,gradeType,int&,char&);

int main()

{     
	 ifstream indata;
	 indata.open("graderoll.dat");
	 int numRecord;   // number of records read in
	 
	 gradeType studentRecord; 
	 char numgrade;
	 
	 
  
	if(!indata)
	{
		cout << "Error opening file. \n";
		cout << "It may not exist where indicated" << endl;
		return 1;
	}

	
	readIt(indata,studentRecord,numRecord, numgrade);
	 
	// output the information 
    for (int count = 0; count < numRecord; count++)
	{
	   cout << studentRecord[count].name << setw(10) 
		    << studentRecord[count].test1
		    << setw(10) << studentRecord[count].test2;
	   cout << setw(10) << studentRecord[count].final
	    << setw(10) << studentRecord[count].findLetterGrade << endl;
	}                
	system("pause");
	return 0;
}



void readIt(ifstream& inData, gradeType gradeRec, int& total,char& numgrade)
{
   total = 0;

   inData.get(gradeRec[total].name, NAMESIZE);
   while (inData)
   {
     
	   inData>>gradeRec[total].test1;
    
	   inData>>gradeRec[total].test2;

	   inData>>gradeRec[total].final;
	 	 
	 total++;     // add one to total

     
	 inData.ignore();
  
    inData.get(gradeRec[total].name, NAMESIZE);
  }

}

float findGradeAvg(gradeType grades, int numGrades, char numgrade)
{
	float sum = 0;

	for (int pos = 0; pos < numGrades; pos++)
	{
		sum = grades[numGrades].test1 + grades[numGrades].test2 + grades[numGrades].final;
		sum = sum / 3;
	}
	return (sum / numGrades);


}

char  findLetterGrade(float numgrade)
{
	char letterGrade = ' ';

	if (numgrade >= 90 && numgrade <= 100)
		letterGrade = 'A';

	else if (numgrade >= 80 && numgrade <= 89)
		letterGrade = 'B';

	else if (numgrade >= 70 && numgrade <= 79)
		letterGrade = 'C';

	else if (numgrade >= 60 && numgrade <= 69)
		letterGrade = 'D';

	else if (numgrade >= 0 && numgrade <= 59)
		letterGrade = 'F';

	return letterGrade;
}


I AM SO CONFUSED!
Last edited on

Dean DeFino           88        98        99         ╠
Sally Johnson          78        89        82         ╠
Bill Benny                75        79        81         ╠
Thomas Billows       78        84        89         ╠
Press any key to continue . . .


THIS IS OUTPUT: // is aligned in cmd however.
Last edited on

TEXT FILE:
Dean DeFino 88 98 99
Sally Johnson 78 89 82
Bill Benny 75 79 81
Thomas Billows 78 84 89
Topic archived. No new replies allowed.