#include <iostream>
#include <string>
#include <fstream>
using namespace std;
void main()
{
ifstream indata;
ofstream outdata;
char name [13][20];
float avg[20];
int sum=0, n, i=0, m,p;
float davg;
char ch;
indata.open("a:nameFile.txt");
if(indata.fail())
{
cout<<"file not open:";
exit (1);
}
while(i<=20)
{
for (i=0;i<20;i++)
indata.getline(name[i],20);
}
for (int k=1; k<=3; k++)
{
indata >> n>>m>>p;
avg[i]=n+m+p/3;
indata.get(ch);
davg = sum/3;
avg[i] = davg;
sum=0, n=0, davg=0, i++;
indata.ignore();
}
cout<<"enter a grade value:\n";
cin>> n;
outdata.open("outfile.txt", ios::out);
for(int k=0; k<20; k++)
{
if(avg[k]>=n)
outdata<<name[k]<<" "<<avg[k]<<endl;
outdata.close();
}
}
missy 0 Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.