i wanna out put the maximum minimum and average score as a statistic category under the student ids and grades in the output file. how do i do that?
here is the code:
#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; };
}
and how do i use assert for preconditions and post conditional functions? i dont understand this that well...