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 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117
|
#include <iostream>
#include <string>
#include <iomanip>
#include <fstream>
using namespace std;
int i;
string names[]={"Bob","ERic","Bill","Joe"};
int ME[4];
int FE[4];
int QA[4];
class myStudent
{
public:
void getNames();
void calcFinalGrade();
void getData();
private:
double FinalGrade;
int newME;
int newFE;
int newQA;
};
void myStudent::getNames()
{
cout<<setw(15)<<names[i];
}
void myStudent::calcFinalGrade() //Calculate into Letter Grade
{
//int ME[4]={5,6,7,8};
//int FE[4]={9,10,11,12};
//int AQ[4]={13,14,15,16};
newME=ME[i];
newFE=FE[i];
newQA=QA[i];
FinalGrade=0.35*newME+.3*newFE+.35*newQA;
//Print Letter Grade
if (FinalGrade>=90 && FinalGrade<100)
cout<<" A"<<endl;
if(FinalGrade>=80 && FinalGrade<89.9)
cout<<" B"<<endl;
if (FinalGrade>=70 && FinalGrade<79.9)
cout<<" C"<<endl;
if (FinalGrade<69.9)
cout<<" FAIL"<<endl;
else
cout<<"Final Grade is out of Range (0-100) or incorrect"<<endl;
}
int main()
{
int ME[4];
ifstream MEfile("MidtermExam.txt");
if (MEfile.is_open())
{
for(int i = 0; i < 4; i++)
{
MEfile>>ME[i];
}
MEfile.close();
}
ifstream FEfile("MidtermExam.txt");
if (FEfile.is_open())
{
for(int i = 0; i < 5; i++)
{
FEfile>>FE[i];
}
FEfile.close();
}
ifstream QAfile("MidtermExam.txt");
if (QAfile.is_open())
{
for(int i = 0; i < 4; i++)
{
QAfile>>ME[i];
}
QAfile.close();
}
for(i=0;i<4;i++)
{
myStudent student [4];
student[i].getNames();
student[i].calcFinalGrade();
}
system("pause");
}
|