max/min/average help?

hello

i wrote the code after so many attempts as a c++ beginner, and i just need to output to the oufile besides the grades of each student a statistics category which has maximum score minimum score and average score. i tried to follow an example but still didnt work with me.

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
  #include "stdafx.h"
#include <iostream>
#include <string>
#include <fstream>
#include <assert.h>

using namespace std;

int openfiles(ifstream& infile, ofstream& outfile);

void Size(ofstream&, int, string);

int main()
{
	int num_student = 4, count, length, score2, w[6];

	ifstream infile, curvingfile; char x;

	ofstream outfile; float score;

	string  key, answer, id;

	do {
		openfiles(infile, outfile);  // function calling

		infile >> key; // answer key

		for (int i = 0; i < num_student; i++) // loop over each student

		{
			infile >> id;

			infile >> answer;

			count = 0;

			length = key.size(); // length represents number of questions in exam from exam1.dat
								 // size is a string function....
			
			Size (outfile, length, answer);

			for (int j = 0; j < length; j++) // loop over each question
			{
				if (key[j] == answer[j])

					count++;
			}

			score = (float) count / length; 

			score2 = (int)(score * 100);

			outfile << id << "     " << score2 << "%";

			if (score2 >= 90)//<-----w[0]

				outfile << "A" << endl;

			else if (score2 >= 80)//<-----w[1]

				outfile << "B" << endl;

			else if (score2 >= 70)//<-----w[2]

				outfile << "C" << endl;

			else if (score2 >= 60)//<-----w[3]

				outfile << "D" << endl;

			else if (score2 >= 50)//<-----w[4]

				outfile << "E" << endl;

			else if (score2 < 50)//<-----w[5]

				outfile << "F" << endl;
		}
		cout << "Would you like to attempt a new trial? (y/n): ";

		cin >> x;
	
	} while (x == 'y' || x == 'Y');

	return 0;
}

int openfiles(ifstream& infile, ofstream& outfile)
{
	string name1, name2, name3, answerstring, curvedata;

	cin >> name1; name2; name3;
	if (name1 == "exit" || name2 == "exit" || name3 == "exit" ) return false;
	 
	cout << "Input the name for the exam file: ";

	cin >> name1;

	infile.open(name1.c_str());

	infile >> answerstring;

	cout << "Input the name for the curving file: ";

	cin >> name2;

	infile.open(name2.c_str());

	infile >> curvedata;

	cout << "Input the name for the output: ";

	cin >> name3;

	outfile.open(name3.c_str());

	return true;
}

void Size(ofstream& outfile, int length, string answer)

{
	bool check;// extra answers, lesser answers...

	if (answer.size() > length)

	{
		outfile << "Unnecessary extra answers";
	}

	else if (answer.size() < length)

	{
		outfile << "The remaining answers are incorrect";
	}

	else { check = false; };
}


thank you anyone in advance! i need this for tomorrow any help is apreciated!
what exactly doesn't work?
Topic archived. No new replies allowed.