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
|
#include <fstream>
#include <iostream>
using namespace std;
ifstream infile;
ofstream outfile;
void grades(int&,int&,int&); // Grades from the input file
int myavg(int,int,int); // Average of the 3 grades
void letters(int&); // Letter Grade: (P)ass or (F)ail
int main()
{
outfile.open("Table.txt");
int x,y,z,average,stuid,letter;
outfile << "\t\t\t\t\tStudent Information" << endl << endl;
outfile << "Student ID\t\tGrade\t\tAverage\t\tLetter Grade" << endl<< endl;
cout << "Please enter the Student's ID" << endl;
cin >> stuid;
while (stuid >= 0) {
cout << "Please enter another Student's ID" << endl;
cin >> stuid;
grades(x,y,z);
letters(x);
outfile << "\t" << stuid << "\t\t\t\t" << myavg(x,y,z) << letters <<
endl;
outfile << "\t\t\t" << x << endl;
outfile << "\t\t\t" << y << endl;
outfile << "\t\t\t" << z << endl;
}
system("PAUSE");
return 0;
}
void grades(int &a,int &b,int &c)// Grades from the input file
{
int x,y,z,;
infile.open("testnum.txt");
infile >> x,y,z;
return;
}
int myavg(int a, int b, int c)// Average of the 3 grades
{
int x,y,z,average;
average = (x + y + z) / 3;
return average;
}
void letters(int& a)// Letter Grade: (P)ass or (F)ail
{
int average;
if (average >= 70)
cout << "P" << endl;
else
cout << "F" << endl;
return;
}
|