Final project help

Pages: 12
Hello, I am working on this project for my first computer science class and was in need of some help. I keep getting this error. error C2664: 'void enterKey(char)' : cannot convert argument 1 from 'char [10]' to 'char'

I think I get what is wrong, that maybe it is just because its trying to convert 10 to just plain char, but I don't understand what I should do to fix the problem. Any help would be great!

I will also be needing more help with the rest of my code later on so this isn't just for this one possibly really simple problem and will update as I go on! Thanks again for any help!


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


using namespace std;







struct Answers
{
	char Answer[10];
};
struct StudentRecord
{
	string name;
	int ID;
	struct Answers Answers;
	double score;
	double average;
	char letter_grade;
};


//function prototypes
void getInformation(StudentRecord*, int&);
void enterKey(char);



int main()

{


	//Variable Declaration
	int No_studs = 0;
	char reply;
	char search;
	char repeat;
	bool check = false;
	int i = 0;
	const int MAX_STUDENTS = 20;
	char key[10];
	StudentRecord *stu;
	int info = 0;

	
	{
		//Enter the number of students
		cout << "How many students are there? ";
		cin >> No_studs;
		stu = new StudentRecord[No_studs];

		//Enter the Answer Key and get info
		enterKey(key);
		getInformation(stu, No_studs);

		//Calculates each student score
		//calculateAvgAndLetter(stu, No_studs, key);


		//Calling the display results in a table format function
		//displayHeading();
		//displayResults(stu, No_studs);

		//sortRecordsByName(stu, No_studs);
		//cout << "Sorted by Name:" << endl;
		//displayResults(stu, No_studs);
		cout << endl << endl;

		
	}


	return 0;
}


void getInformation(StudentRecord* stu, int& No_studs)
{

	for (int i = 0; i < No_studs; i++)
	{


		cout << "Student " << i + 1 << " information: " << endl;
		cout << "Name: ";
		cin >> stu[i].name;
		cout << "ID: ";
		cin >> stu[i].ID;
		cout << "Enter this students 10 answers: " << endl;
		for (int j = 0; j < 10; j++)
		{
			cout << "Answer " << j + 1 << ": ";
			cin >> stu[i].Answers.Answer[j];
		}
		

	}

}
void enterKey(char key[])
{
	cout << "Please enter the answer key." << endl;
	for (int index = 0; index < 10; index++)
	{
		cout << "Answer " << index + 1 << ": ";
		cin >> key[index];

	}

}
Look at your prototype:
void enterKey(char);

Then look at your definition:
void enterKey(char key[])
closed account (48T7M4Gy)
void enterKey(char[]); Don't forget you need to limit the char array parameter.

BTW why don't you scrap struct Answers and include the array in the StudentRecord struct?
closed account (48T7M4Gy)
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
#include <iostream>
#include <string>

using namespace std;

struct StudentRecord
{
	string name;
	int ID;
	char Answer[10];
	double score;
	double average;
	char letter_grade;
};

void getInformation(StudentRecord*, int);
void enterKey(char[], int);

int main()
{
	int No_studs = 0;
	char reply;
	char search;
	char repeat;
	bool check = false;
	int i = 0;
	const int MAX_STUDENTS = 20;
	
	const int limit = 10;
	char key[limit];
	
	StudentRecord *stu;
	int info = 0;
	
	{
		cout << "How many students are there? ";
		cin >> No_studs;
		stu = new StudentRecord[No_studs];
		
		enterKey(key, limit);
		
		getInformation(stu, No_studs);
	}

	system("pause");
	return 0;
}

void getInformation(StudentRecord* record, int classSize)
{
	for (int i = 0; i < classSize; i++)
	{
		cout << "Student " << i + 1 << " information: " << endl;

		cout << "Name: ";
		cin >> record[i].name;

		cout << "ID: ";
		cin >> record[i].ID;

		cout << "Enter this students 10 answers: " << endl;
		for (int j = 0; j < 10; j++)
		{
			cout << "Answer " << j + 1 << ": ";
			cin >> record[i].Answer[j];
		}
	}
}

void enterKey(char aKey[], int aLimit)
{
	cout << "Please enter the answer key." << endl;
	for (int index = 0; index < aLimit; index++)
	{
		cout << "Answer " << index + 1 << ": ";
		cin >> aKey[index];
	}
}
Okay, so I changed it up a little bit, I noticed that I was supposed to have this read from a .txt file and this is where I am. I don't quite understand why my loop isn't working, like it says that it needs a pointer-to-object type. What is that?

p.s. Sorry I haven't responded lately, I was pretty sick all day yesterday!

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


#include <iostream>
#include <string>
#include <fStream>

using namespace std;


//function prototypes
void getInfo(int ID, string last, string first, char answers[10]);
void getKey(char key[10]);

int main()
{
	int ID = 0;
	string last;
	string first;
	char answers[10];
	char key[10];


	getInfo(ID, last, first, answers);
	getKey(key);
	
}
void getInfo(int ID, string last, string first, char answers[10])
{
	ifstream inFile("student.txt"); //open file to read from 

	while (inFile >> ID >> last >> first >> answers[0] >> answers[1] >> answers[2] >> answers[3] >> answers[4] >> answers[5] >> answers[6] >> answers[7] >> answers[8] >> answers[9])
	{
		cout << ID << ", " << last << " " << first << ", " << answers[0] << answers[1] << answers[2] << answers[3] << answers[4] << answers[5] << answers[6] << answers[7] << answers[8] << answers[9] << endl;
	}
}
void getKey(char key)
{
	cout << "Please enter the answer key." << endl;
	for (int index = 0; index < 10; index++)
	{
		cout << "Answer " << index + 1 << ": ";
		cin >> key[index];

	}
}

Nevermind! I saw what you did with it kemort! Makes more sense there! Thank you!

I am a little stuck on another part now, I don't really understand how to get this to display in ascending order by name, what can I do for that?
Last edited on
...
Last edited on
closed account (48T7M4Gy)
To get the info in order you need to sort it and that means you need to store the info as it comes from the file in some sort of container eg array vector map etc which can all be sorted ( with varying degrees of difficulty with standard functions ) Of course, you can write your own.

Check out the tutorials on STL containers.
Okay, I've got more in to this now. It currently says I have 1 error which once I get that right I may have 10 more errors lol, but this is what I have. Any ideas?
Last edited on
closed account (48T7M4Gy)
#include <fstream> not #include <fStream>
Thank you kemort! I probably wouldn't have noticed that!
closed account (48T7M4Gy)
Just a lucky glance schellman2. Does the program run?
My program doesn't run, could not convert 'stu' from 'StudentRecord*' to 'StudentRecord' is my error. Like I see what is wrong but I don't know what to do to fix it..

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
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
#include <iostream>
#include <iomanip>
#include <string>
#include <fstream>

using std::cout;
using namespace std;


struct StudentRecord
{
	char Answer[10];
	string name;
	int ID;
	struct Answers;
	double score;
	double average;
	char letter_grade;
};




//function prototypes
void getInfo(int, string, string, char[10]);
void enterKey(char key[10]);
void calculateScore(char[10], char[10], int, double, char);
void sortName(StudentRecord, int);
void displayHeading();
void displayResults(int, string, string, char[10], int, double, char);



int main()
{
	//user defined variables
	int ID = 0;
	string last;
	string first;
	int numStudents = 0;
	char answers[10];
	char key[10];
	char letter_grade = 'A';
	int score = 0;
	double average = 0.0;
	StudentRecord *stu;
	

	stu = new StudentRecord[numStudents];

	getInfo(ID, last, first, answers);
	enterKey(key);
	calculateScore(answers, key, score, average, letter_grade);
	displayHeading();
	displayResults(ID, last, first, answers, score, average, letter_grade);
	sortName(stu, numStudents);
}
void getInfo(int ID, string last, string first, char answers[10])
{
	ifstream inFile("student.txt"); //open file to read from 

	while (inFile >> ID >> last >> first >> answers[0] >> answers[1] >> answers[2] >> answers[3] >> answers[4] >> answers[5] >> answers[6] >> answers[7] >> answers[8] >> answers[9]);
	{
		cout << ID << ", " << last << " " << first << ", " << answers[0] << answers[1] << answers[2] << answers[3] << answers[4] << answers[5] << answers[6] << answers[7] << answers[8] << answers[9] << endl;
	}
}
//void enterKey(char key[])
{
	cout << "Please enter the answer key." << endl;
	for (int index = 0; index < 10; index++)
	{
		cout << "Answer " << index + 1 << ": ";
		cin >> key[index];
	}

}
void calculateScore(StudentRecord * stu, char answers[10], char key[10], int score, double average, char letter_grade)
{
	int points1 = 0;
	int points2 = 0;
	int points3 = 0;
	int points4 = 0;
	int points5 = 0;
	int points6 = 0;
	int points7 = 0;
	int points8 = 0;
	int points9 = 0;
	int points10 = 0;




	//gather's the number of points earned
	for (int index = 0; index < 10; index++)
	{
		if (stu[index].Answer[0] == key[0])
			points1 = 5;
		else
			points1 = 0;

		if (stu[index].Answer[1] == key[1])
			points2 = 5;
		else
			points2 = 0;

		if (stu[index].Answer[2] == key[2])
			points3 = 5;
		else
			points3 = 0;

		if (stu[index].Answer[3] == key[3])
			points4 = 5;
		else
			points4 = 0;

		if (stu[index].Answer[4] == key[4])
			points5 = 5;
		else
			points5 = 0;
		if (stu[index].Answer[5] == key[5])
			points6 = 5;
		else
			points6 = 0;

		if (stu[index].Answer[6] == key[6])
			points7 = 5;
		else
			points7 = 0;

		if (stu[index].Answer[7] == key[7])
			points8 = 5;
		else
			points8 = 0;

		if (stu[index].Answer[8] == key[8])
			points9 = 5;
		else
			points9 = 0;

		if (stu[index].Answer[9] == key[9])
			points10 = 5;
		else
			points10 = 0;

		//adds all of the scored points together to get raw total
		stu[index].score = points1 + points2 + points3 + points4 + points5 + points6 + points7 + points8 + points9 + points10;
		//
		stu[index].average = stu[index].score * 2;

		//determines the students average letter grade
		if ((stu[index].average >= 90) && (stu[index].average <= 100))
			stu[index].letter_grade = 'A';

		else if ((stu[index].average >= 80) && (stu[index].average <= 89))
			stu[index].letter_grade = 'B';

		else if ((stu[index].average >= 70) && (stu[index].average <= 79))
			stu[index].letter_grade = 'C';

		else if ((stu[index].average >= 60) && (stu[index].average <= 69))
			stu[index].letter_grade = 'D';

		else if ((stu[index].average >= 0) && (stu[index].average <= 59))
			stu[index].letter_grade = 'F';
	}
}

void sortName(StudentRecord *stu, int numStudents)
{
	for (int i = 0; i < numStudents; i++)
	{
		for (int j = 0; j < numStudents - 1 - i; j++)
		{
			if (stu[j].name > stu[j + 1].name)
				swap(stu[j], stu[j + 1]);
		}
	}
}

void displayHeading()
{
	cout << setw(10) << "Student ID";
	cout << setw(15) << "Student Name";
	cout << setw(10) << "Answers";
	cout << setw(10) << "Total points";
	cout << setw(10) << "Average";
	cout << setw(15) << "Letter Grade";
	cout << endl;
}



void displayResults(StudentRecord *stu, int ID, string last, string first, char answers[10], int score, double average, char letter_grade)
{
	int index = 0;
	int x = 0;

	for (int x = 0; x < 10; x++)
	{
		//Displays all students
		cout << setw(10) << stu[x].ID;
		cout << left << setw(15) << stu[x].name;
		for (int y = 0; y<5; y++)
		{
			cout << setw(2) << stu[x].Answer[y] << "";
		}
		cout << setw(10) << stu[x].score;
		cout << setw(10) << stu[x].average;
		cout << setw(15) << stu[x].letter_grade;
		cout << endl;
	}
	//Displays students admitted into the program
	for(int index = 0; index < 10; index++)
	{
		if (stu[index].letter_grade == 'A' || stu[index].letter_grade == 'B')
		{
			//Creates table heading
			cout << "Students Admitted to the Graduate Program" << endl;

			displayHeading();

			//Displays student info
			cout << setw(10) << stu[index].ID;
			cout << left << setw(15) << stu[index].name;
			for (int y = 0; y < 10; y++)
			{
				cout << setw(2) << stu[index].Answer[y] << "";
			}
			cout << setw(10) << stu[index].score;
			cout << setw(10) << stu[index].average;
			cout << setw(10) << stu[index].letter_grade;
			cout << endl;
		}
	}
	cout << endl << endl;
	//Displays student with conditional admission
	for(int index = 0; index < 10; index++)
	{
		if (stu[index].letter_grade == 'C')
		{
			//Creates table heading
			cout << "Students with Conditional Admission:" << endl;
			displayHeading();

			//Displays student info
			cout << setw(10) << stu[index].ID;
			cout << left << setw(15) << stu[index].name;
			for (int y = 0; y < 10; y++)
			{
				cout << setw(2) << stu[index].Answer[y] << "";
			}
			cout << setw(10) << stu[index].score;
			cout << setw(10) << stu[index].average;
			cout << setw(10) << stu[index].letter_grade;
			cout << endl;
		}
	}
	//Displays students that are not allowed
	cout << endl << endl;
	for(int index = 0; index < 10; index++)
	{
		if (stu[index].letter_grade == 'F')
		{
			//Creates table heading
			cout << "Students Not Allowed Admission: " << endl;
			displayHeading();

			//Displays student info
			cout << setw(10) << stu[index].ID;
			cout << left << setw(15) << stu[index].name;
			for (int y = 0; y < 10; y++)
			{
				cout << setw(2) << stu[index].Answer[y] << "";
			}
			cout << setw(10) << stu[index].score;
			cout << setw(10) << stu[index].average;
			cout << setw(10) << stu[index].letter_grade;
			cout << endl;
		}
	}

}
Last edited on
closed account (48T7M4Gy)
Take just one function call:

line 53: calculateScore(answers, key, score, average, letter_grade);
line 77: void calculateScore(StudentRecord * stu, char answers[10], char key[10], int score, double average, char letter_grade)

Are you sure the first two parameters are compatible? I can easily see what stu is but what is answers doing there?
okay, i see that, no idea why I put answers in there. Might have been thinking of another part of my code and just put it in there by mistake.. and I am not sure that they are compatible.

Does stu look correct to be there? It seems like a lot of my troubles are coming out of structures.
closed account (48T7M4Gy)
Does stu look correct to be there?
It looks right to me but what you should do is test it and satisfy yourself by puttin in a loop to display all the student records at each stage to make sure the array is being used the way you intended.
Okay, so I got a little help from my professor and now my code runs and it displays everything, just doesn't display any information, it's all garbage. I am having a little bit of trouble getting the file to read because I'm just confusing myself with the structure in my getInfo function!


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

using std::cout;
using namespace std;


struct StudentRecord
{
	char Answer[10];
	string name;
	int ID;
	char Answers[10];
	double score;
	double average;
	char letter_grade;
};




//function prototypes
void getInfo(int, string, string, char[10]);
void enterKey(char key[10]);
void calculateScore(char[10], StudentRecord[]);
void sortName(StudentRecord[], int);
void displayHeading();
void displayResults(StudentRecord[]);



int main()
{
	//user defined variables
	int ID = 0;
	string last;
	string first;
	int No_studs = 0;
	char answers[10];
	char key[10];
	char letter_grade = 'A';
	int score = 0;
	double average = 0.0;
	StudentRecord stu[10];


	//stu = new StudentRecord[No_studs];

	getInfo(ID, last, first, answers);
	enterKey(key);
	calculateScore(key, stu);
	displayHeading();
	displayResults(stu);
	sortName(stu, No_studs);
}
void getInfo(StudentRecord stu[])
{
	ifstream inFile;  //Input file stream to open file and read 
	int i = 0;
	inFile.open("student.txt"); //open file to read from 

	if (!inFile) //check to see if file is open
		cout << "\n\n**** ERROR OPENING FILE. ******\n" << endl;
	else
	{
		while (!inFile.eof()) //while not at end of file(eof)
		{
			inFile >> stu[i].ID;
			inFile.getline.stu[i].name;
			stu[i].name = stu[i].name;
			inFile >> stu[i].Answers;
			i++;
			if (inFile.eof())
				break;
		}
	}
}
closed account (48T7M4Gy)
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
#include <iostream>
#include <string>
#include <fstream>

using std::cout;
using std::endl;
using std::string;
using std::ifstream;

struct Student // cut down for demo
{
	int ID;
	string name;
	char answers[2];
};

int getInfo(Student[], const int);

int main()
{
	const int limit = 10;
	Student stu[limit];

	int no_of_students = getInfo(stu, limit);

	for (int i = 0; i < no_of_students; i++)
	{
		cout << stu[i].ID << ' ' << stu[i].name << endl;

		for (int j = 0; j < 2; j++)
			cout << stu[i].answers[j] << endl;
	}

	return 0;
}

int getInfo(Student aRecord[], const int aLimit)
{
	ifstream inFile;  //Input file stream to open file and read 
	int i = 0;
	inFile.open("student.txt"); //open file to read from 

	if (!inFile) //check to see if file is open
		cout << "\n\n**** ERROR OPENING FILE. ******\n" << endl;
	else
	{
		i = 0;
		while (inFile >> aRecord[i].ID && i < aLimit)
		{
			inFile >> aRecord[i].name;
			
			for (int index = 0; index < 2; index++)
				inFile >> aRecord[i].answers[index];
			i++;
		}
	}

	return i;
}


student.txt
2 Smith 1 8
55 Brown 5 2

Output
2 Smith
1
8
55 Brown
5
2
Press any key to continue . . .
Last edited on
This helped out a lot! Okay, assuming that all of my code is correct it should display everything correctly as far as numbers being correct, but I'm getting garbage for my display. I got it to display the first and last name how I wanted it, but now the rest is still garbage. Here is all of my code now if you could check out what I mean!


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
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
#include <iostream>
#include <iomanip>
#include <string>
#include <fstream>

using std::cout;
using namespace std;

const int aLimit = 10;

struct StudentRecord
{
	char Answer[10];
	string first;
	string last;
	int ID;
	char Answers[10];
	int score;
	double average;
	char letter_grade;
	string name;
};




//function prototypes
int getInfo(StudentRecord[]);
void enterKey(char key[10]);
void calculateScore(char[10], StudentRecord[]);
void sortName(StudentRecord[], int);
void displayHeading();
void displayResults(StudentRecord[]);



int main()
{
	//user defined variables
	int ID = 0;
	string last;
	string first;
	int No_studs = 0;
	char answers[10];
	char key[10];
	char letter_grade = 'A';
	int score = 0;
	double average = 0.0;
	


	
	StudentRecord stu[aLimit];

	int no_of_students = getInfo(stu);

	for (int i = 0; i < no_of_students; i++)
	{
		

		for (int j = 0; j < 10; j++);
			
	}

	getInfo(stu);
	enterKey(key);
	calculateScore(key, stu);
	displayHeading();
	displayResults(stu);
	sortName(stu, No_studs);
}
int getInfo(StudentRecord stu[])
{
	ifstream inFile;  //Input file stream to open file and read 
	int i = 0;
	inFile.open("student.txt"); //open file to read from 

	if (!inFile) //check to see if file is open
		cout << "\n\n**** ERROR OPENING FILE. ******\n" << endl;
	else
	{
		i = 0;
		string first;
		string last;
		while (inFile >> stu[i].ID && i < aLimit)
		{
			inFile >> stu[i].last;
			inFile >> stu[i].first;

			for (int index = 0; index < 10; index++)
				inFile >> stu[i].Answers[index];
			i++;
		}
	}

	return i;
}
void enterKey(char key[])
{
	cout << "Please enter the answer key." << endl;
	for (int index = 0; index < 10; index++)
	{
		cout << "Answer " << index + 1 << ": ";
		cin >> key[index];
	}

}
void calculateScore(char key[10], StudentRecord  stu[])
{
	int pts1 = 0;
	int pts2 = 0;
	int pts3 = 0;
	int pts4 = 0;
	int pts5 = 0;
	int pts6 = 0;
	int pts7 = 0;
	int pts8 = 0;
	int pts9 = 0;
	int pts10 = 0;




	//gather's the number of points earned
	for (int index = 0; index < 10; index++)
	{
		if (stu[index].Answer[0] == key[0])
			pts1 = 5;
		else
			pts1 = 0;

		if (stu[index].Answer[1] == key[1])
			pts2 = 5;
		else
			pts2 = 0;

		if (stu[index].Answer[2] == key[2])
			pts3 = 5;
		else
			pts3 = 0;

		if (stu[index].Answer[3] == key[3])
			pts4 = 5;
		else
			pts4 = 0;

		if (stu[index].Answer[4] == key[4])
			pts5 = 5;
		else
			pts5 = 0;
		if (stu[index].Answer[5] == key[5])
			pts1 = 5;
		else
			pts1 = 0;

		if (stu[index].Answer[6] == key[6])
			pts2 = 5;
		else
			pts2 = 0;

		if (stu[index].Answer[7] == key[7])
			pts3 = 5;
		else
			pts3 = 0;

		if (stu[index].Answer[8] == key[8])
			pts4 = 5;
		else
			pts4 = 0;

		if (stu[index].Answer[9] == key[9])
			pts5 = 5;
		else
			pts5 = 0;

		//adds all of the scored points together to get raw total
		stu[index].score = pts1 + pts2 + pts3 + pts4 + pts5 + pts6 + pts7 + pts8 + pts9 + pts10;
		//
		stu[index].average = stu[index].score * 2;

		//determines the students average letter grade
		if ((stu[index].average >= 90) && (stu[index].average <= 100))
			stu[index].letter_grade = 'A';

		else if ((stu[index].average >= 80) && (stu[index].average <= 89))
			stu[index].letter_grade = 'B';

		else if ((stu[index].average >= 70) && (stu[index].average <= 79))
			stu[index].letter_grade = 'C';

		else if ((stu[index].average >= 60) && (stu[index].average <= 69))
			stu[index].letter_grade = 'D';

		else if ((stu[index].average >= 0) && (stu[index].average <= 59))
			stu[index].letter_grade = 'F';
	}
}

void sortName(StudentRecord stu[], int No_studs)
{
	bool swap = true;
	int j = 0;
	StudentRecord temp;

	while (swap)
	{
		swap = false;
		j++;
		for (int i = 0; i < No_studs - j; i++)
		{

			if (stu[i].name.compare(stu[i + 1].name.c_str()) > 0)
			{
				temp.name = stu[i].name;
				stu[i].name = stu[i + 1].name;
				stu[i + 1].name = temp.name;
				swap = true;
			}


		}
	}
}

void displayHeading()
{
	cout << setw(10) << "Student ID";
	cout << setw(15) << "Student Name";
	cout << setw(10) << "Answers";
	cout << setw(10) << "Total Pts";
	cout << setw(10) << "Average";
	cout << setw(15) << "Letter Grade";
	cout << endl;
}



void displayResults(StudentRecord stu[])
{
	int index = 0;
	int x = 0;

	for (int x = 0; x < 10; x++)
	{
		//Displays all students
		cout << " " << setw(5) << stu[x].ID;
		cout << setw(10) << stu[x].last << stu[x].first;
		for (int y = 0; y<10; y++)
		{
			cout << setw(2) << stu[x].Answer[y] << "";
		}
		cout << setw(10) << stu[x].score;
		cout << setw(10) << stu[x].average;
		cout << setw(15) << stu[x].letter_grade;
		cout << endl;
	}
	//Displays students admitted into the program
	for (int i = 0; i < 10; i++)
	{
		if (stu[i].letter_grade == 'A' || stu[i].letter_grade == 'B')
		{
			//Creates table heading
			cout << "Students Admitted to the Graduate Program" << endl;

			displayHeading();

			//Displays student info
			cout << left << setw(10) << stu[i].ID;
			cout << left << setw(15) << stu[i].last << stu[i].first;
			for (int y = 0; y < 10; y++)
			{
				cout << setw(2) << stu[i].Answer[y] << "";
			}
			cout << setw(10) << stu[i].score;
			cout << setw(10) << stu[i].average;
			cout << setw(10) << stu[i].letter_grade;
			cout << endl;
		}
	}
	cout << endl << endl;
	//Displays student with conditional admission
	for (int i = 0; i < 10; i++)
	{
		if (stu[i].letter_grade == 'C')
		{
			//Creates table heading
			cout << "Students with Conditional Admission:" << endl;
			displayHeading();

			//Displays student info
			cout << setw(10) << stu[i].ID;
			cout << left << setw(15) << stu[i].name;
			for (int y = 0; y < 10; y++)
			{
				cout << setw(2) << stu[i].Answer[y] << "";
			}
			cout << setw(10) << stu[i].score;
			cout << setw(10) << stu[i].average;
			cout << setw(10) << stu[i].letter_grade;
			cout << endl;
		}
	}
	//Displays students that are not allowed
	cout << endl << endl;
	for (int i = 0; i < 10; i++)
	{
		if (stu[i].letter_grade == 'F')
		{
			//Creates table heading
			cout << "Students Not Allowed Admission: " << endl;
			displayHeading();

			//Displays student info
			cout << setw(10) << stu[i].ID;
			cout << left << setw(15) << stu[i].last << stu[i].first;
			for (int y = 0; y < 10; y++)
			{
				cout << setw(2) << stu[i].Answer[y] << "";
			}
			cout << setw(10) << stu[i].score;
			cout << setw(10) << stu[i].average;
			cout << setw(10) << stu[i].letter_grade;
			cout << endl;
		}
	}

}
closed account (48T7M4Gy)
Where is your sample data? I can't do anything until you produce a data file with about 5 student details on it.

Just one thing I noticed in you student struct Answer and Answers is not good naming.

What is line 61/62 doing going nowhere?
Pages: 12