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
|
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
#define Size 20
using namespace std;
struct Stud{
string Name;
long ID;
float GPA, SPoints;
int SUnits;
char Grade;
};
struct PStud{
Stud list[Size];
};
void Process_Data(ifstream, Stud, PStud &, int &);
float Assign_GPA(char);
void Process(int, float, float &, int &);
bool Verify(int);
bool Open_File(ifstream &);
bool Open_File2(ofstream &);
int main()
{
Stud TEMP[Size];
PStud Stud;
string Name, FName;
ifstream Input;
ofstream Output;
int Num = 0;
int counter = 0, SUnits = 0, Tot_Units = 0;
float SPoints = 0, Tot_Points = 0, GPA, Tot_GPA;
if (Open_File(Input))
{
if (Open_File2(Output))
{
Output << setprecision(2) << fixed << showpoint;
cout << left << setw(27) << cout << left<<setw(27)<<"\n\nStudent Name" << setw(10)<<"ID "<<setw(10)<<"Units" <<setw(8)<<"GPA" <<endl;
cout <<"====================================================\n";
Output << left<<setw(27)<<"\n\nStudent Name" << setw(10)<<"ID "<<setw(10)<<"Units" <<setw(8)<<"GPA" <<endl;
Output <<"====================================================\n";
getline(Input,TEMP[Num].Name);
while(!Input.eof())
{
Input >> TEMP[Num].ID;
Process_Data(Input, TEMP, Stud, Num);
cout << setw(25) << Name << setw(10) << TEMP[Num].ID << setw(10) << TEMP[Num].SUnits << setw(8) << TEMP[Num].GPA <<endl;
Output << setprecision(2)<<fixed;
Output << setw(25) << Name << setw(10) << TEMP[Num].ID << setw(10) << TEMP[Num].SUnits << setw(8) << TEMP[Num].GPA <<endl;
counter++ ;
Input.ignore(10,'\n');
getline(Input,Name);
}
Tot_GPA = Tot_Points / Tot_Units;
cout <<"==================================================\n";
cout <<"Group of "<<counter<<setw(25)<<" Students Totals" <<setw(10)<< Tot_Units << setw(10)<< Tot_GPA << endl << endl ;
Output <<"==================================================\n\n";
Output <<"Group of "<<counter<<setw(25)<<" Students Totals" <<setw(10)<< Tot_GPA << setw(10)<< Tot_GPA << endl << endl ;
cout << endl << endl ;
}
}
return 0;
}
|