void readstuid (int& studid, ifstream& inputfile){
inputfile>>studid;
//reads studentid from file
}
void grade (int& grade1, int& grade2, int& grade3, ifstream & inputfile){ //reads in grade from file
inputfile>>grade1>>grade2>>grade3;
}
void score(double& average, int grade1, int grade2, int grade3){
int sum = 0;
sum+= grade1 + grade2 + grade3;
average = sum/3.0; //calc average score
return;
}
void Table (int studid, int grade1, int grade2, int grade3, double average, char pass){ //prints table value under headings
cout<<setw(5)<<studid<<setw(10)<<grade1<<setw(10)<<grade2<<setw(10)<<grade3
<<setw(13)<<average<<setw(10)<<pass<<endl;
}
double CalcPassPer (int passstudent){
double percent; //must declare percent
percent = passstudent/5.0 * (100); //computing the percent
return percent;
}
void perpass (double percent) { //This function prints the percent directly under the chart
cout<<"\n"<<percent<<"% of students passed"<<endl;
}
if (average >= 70){
pass='P';
passstudent++; //count the number of students who passed
}
else
pass='F';
Table (studid, grade1, grade2, grade3, average, pass);
readstudid(studid,infile);
}
//Percentage function and Print Percent function is called outside of loop.
percent=CalcPassPer (passstudent);
perpass (percent);