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 75 76 77 78 79 80 81 82 83 84 85 86
|
#include<iostream>
#include<fstream>
using namespace std;
void Input(int Score[5][4],int ID[5]);
void Output(int Score[5][4], int ID[5]);
void Avg(int Score[5][4],int ID[5], int AvgOne[5],int AvgTwo[5]);
//int LetterGrade(int Score[5][4], int AvgOne,int AvgTwo, char LGrade1, char LGrade2);
int main()
{
int Score[5][4];
int AvgOne[5];
int AvgTwo[5];
int ID[5];
char GradeWeighted[5];
char GradeAvg[5];
char LGrade1;
char LGrade2;
Input(Score,ID);
Output(Score,ID);
Avg(Score,ID,AvgOne,AvgTwo);
system("pause");
return 0;
}
void Input(int Score[5][4],int ID[5])
{ ofstream Student("Student.dat",ios::app);
for(int i=0;i<5;i++)
{cout<<"\nEnter ID of Student["<<i<<"]: ";
cin>>ID[i];
Student<<ID[i]<<" ";
for(int j=0;j<4;j++)
{cout<<"\nEnter Test Score["<<j<<"] of Student["<<i<<"]: ";
cin>>Score[i][j];
Student<<Score[i][j]<<" ";}
Student<<endl;}
Student.close();
}
void Output(int Score[5][4], int ID[5])
{
cout<<"StudID\tScore 1\tScore 2\tScore 3\tScore 4\t"<<endl;
ifstream Student("Student.dat");
Student>>ID[0]>>Score[0][0];
for(int i=0;i<5&&Student.good();i++)
{
cout <<ID[i]<<"\t";
Student>>ID[i];
for(int j=0;j<4&&Student.good();j++)
{
cout<<Score[i][j]<<" ";
Student>>Score[i][j];
}
cout<<endl;
}
Student.close();
}
void Avg(int Score[5][4],int ID[5], int AvgOne[5],int AvgTwo[5])
{
cout<<"StudID\tScore 1\tScore 2\tScore 3\tScore 4\tAvg1\tAvg2"<<endl;
ifstream Student("Student.dat");
Student>>ID[0]>>Score[0][0];
for(int i=0;i<5&&Student.good();i++)
{
cout <<ID[i]<<"\t";
Student>>ID[i];
for(int j=0;j<4&&Student.good();j++)
{
cout<<Score[i][j]<<" ";
Student>>Score[i][j];
}
AvgOne[i]=(Score[i][1]+Score[i][2]+Score[i][3]+Score[i][4])*.25;
AvgTwo[i]=(0.2*(Score[i][1])+0.3*(Score[i][2])+0.3*(Score[i][3])+0.2*(Score[i][4]))*25;
cout<<AvgOne[i]<<" "<<AvgTwo[i];
cout<<endl;
}
Student.close();
}
|