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
|
#include <iostream>
#include <iomanip>
#include <fstream>
#include <cstdlib>
int asscalc(int [], int);
int calc(int, int, int, int, int);
using namespace std;
int main(){
ifstream infile;
ofstream outfile, outfileagain;
const int outof = 400;
const int ELEMENTS = 10;
int ass[ELEMENTS], percent, stdntid, ex, tot = 0, mi, fin, cl, pts, i, countA = 0, countB = 0, countC = 0, countD = 0, countF = 0, sign;
double pct;
string gr;
infile.open("C:\\Users\\leewi\\Desktop\\Computer Programs & Projects\\C++\\BentleyCIS22B\\Ass1\\ass1data.txt");
outfile.open("C:\\Users\\leewi\\Desktop\\Computer Programs & Projects\\C++\\BentleyCIS22B\\Ass1\\studentreportoutputfile.txt");
if(infile.fail()){
cout << "Can't Open File";
exit(0);
}
do{
infile >> stdntid;
if (stdntid <= 10000000){
outfile << 0;
}
infile >> ex;
for(i = 0; i < 10; i++){
infile >> ass[i];
}
infile >> mi;
infile >> fin;
infile >> cl;
outfile << stdntid << setw(4) << ex << setw(4);
for (i = 0; i < 10; i++){
outfile << ass[i] << setw(3);
}
tot = asscalc(ass, i);
pts = calc(ex, tot, mi, fin, cl);
pct = ((static_cast<double>(pts)/outof) * 100) + 0.5;
percent = static_cast<int>(pct);
sign = static_cast<int>(pct) % 10;
if (pct >= 90){
gr = "A";
countA++;
}
else if (pct >= 80){
gr = "B";
countB++;
}
else if (pct >= 70){
gr = "C";
countC++;
}
else if (pct >= 60){
gr = "D";
countD++;
}
else{
gr = "F";
countF++;
}
outfile << setw(5) << tot << setw(4) << mi << setw(5) << fin << setw(4) << cl << setw(5) << pts << setw(5) << setprecision(2) << percent << setw(4) << gr;
if (percent == 100){
outfile << "+" << endl;
}
else if (sign < 2){
outfile << "-" << endl;
}
else if (sign > 7){
outfile << "+" << endl;
}
else{
outfile << endl;
}
}while(!infile.eof());
cout << "Check Student Report on student \"reportoutputfile.txt\" & Grades on \"grades.txt\"" << endl;
infile.close();
outfile.close();
return 0;
}
int calc(int ex, int tot, int mi, int fin, int cl){
int pts;
pts = ex + tot + mi + fin + cl;
return pts;
}
int asscalc(int ass[], int i){
int tot = 0;
int highest;
const int ELEMENTS = 10;
for (i = 1; i < ELEMENTS; i++){
if(ass[i] > highest)
highest = ass[i];
}
for(i = 0; i < 9; i++){
tot += ass[i];
}
return tot;
}
|