#include <iostream>
#include <fstream>
#include <cstring>
#include <iomanip>
using namespace std;
string result(float); // used to return fail or pass

int main()
{
	char name[200][50]; // To hold name of the students
	float score[200]; // To hold score of the students
	int i = 0; // Counter
	float sum = 0, average = 0; // sum for total scores of all students, average used to calculate average score of all students
	fstream filein("inputdata.txt", ios::in); // input file
	fstream fileout("outputdata.txt", ios::out); // output file
	
	if (!filein)
	{
		cout << "No data file found!" << endl;
		return 0;
	}
	
	while (!filein.eof())
	{
		filein.getline(name[i], 50, '\t');
		
		if (filein.eof())
		{
			break;
		}
		
		filein >> score[i];
		sum += score[i];
		fileout << name[i] << "\t" << score[i] << "\t" << result(score[i]) << endl;
		i++;
		filein.ignore();
	}

	average = sum / i;
	
	fileout << endl << "Average = " << average;
	
	filein.close();
	fileout.close();
}

string result(float score)
{
	if (score < 50)
	{
		return "fail";
	}
	else
	{
		return "pass";
	}
}
