Can anyone take a look at this assignment. How to change A to A+,B to A, C to A-,etc. #include <iostream> #include <fstream> #include <string> #include <iomanip> using namespace std; const int quizes = 6; void heading(); void printdata(int&,int,string,string); void avgGrd(int,int,int,int,int,double&,char&); void avgSc(int,int,int,int,int,double&); void highlow(int,int,int,int,int&,int&); void grading(double,char&); void avgQ(double,double&,int&); void printStudentQuiz(int); void main() { ifstream data; string filename, Lname, Fname; int id, q1, q2, q3, q4, final, no = 1; int countq1 = 0,countq2 = 0,countq3 = 0,countq4 = 0, countf = 0, countavg = 0; double Tq1 = 0, Tq2= 0, Tq3= 0, Tq4= 0, Tfinal= 0, Tavg= 0; double avgscore; char grd; cout << "Enter the file name: "; cin >> filename; filename += ".txt"; data.open(filename.c_str()); heading(); data.ignore(80, '\n'); data >> id >> Lname >> Fname >> q1 >> q2 >> q3 >> q4 >> final; while (!data.eof()) { printdata(no,id,Lname,Fname); avgGrd(q1,q2,q3,q4,final,avgscore,grd); avgQ(q1,Tq1,countq1); avgQ(q2,Tq2,countq2); avgQ(q3,Tq3,countq3); avgQ(q4,Tq4,countq4); avgQ(final,Tfinal,countf); avgQ(avgscore,Tavg,countavg); data >> id >> Lname >> Fname >> q1 >> q2 >> q3 >> q4 >> final; } cout << setw(75) << "----------------------------------------" << endl; cout << setw(43) << Tq1/countq1 << setw(6) << Tq2/countq2 << setw(6) << Tq3/countq3 << setw(6) << Tq4/countq4 << setw(6) << Tfinal/countf << setw(6) << Tavg/countavg << endl << endl; data.close(); } void heading() { cout << endl << " Fall 2011 Studen Grade report: " << endl << endl; cout << left << setw(4) << "No." << setw(8) << "ID" << setw(14) << "Last Name" << setw(13) << "First Name" << setw(6) << "Quiz1" << setw(6) << "Quiz2" << setw(6) << "Quiz3" << setw(6) << "Quiz4" << setw(7) << "Final" << setw(5) << "Avg" << setw(2) << "Grd" << endl; cout << "------------------------------------------------" << "-------------------------------" << endl; } void printdata(int& no,int id,string ln,string fn) { cout << left << setw(4) << no << setw(8) << id << setw(14) << ln << setw(13) << fn << setw(3); no++; } void avgGrd(int q1, int q2, int q3, int q4, int final, double& avg, char& grd) { avgSc(q1,q2,q3,q4,final,avg); grading(avg,grd); cout << right; printStudentQuiz(q1); printStudentQuiz(q2); printStudentQuiz(q3); printStudentQuiz(q4); cout << final << setw(7) << avg << setw(3)<< grd << endl; } void avgSc(int q1, int q2, int q3, int q4, int final, double& avg) { int highest, lowest; highlow(q1,q2,q3,q4,highest,lowest); cout << fixed << setprecision(1); avg = double(q1+q2+q3+q4+final*2+highest-lowest)/quizes; } void highlow(int q1,int q2,int q3,int q4,int& high,int& low) { high = q1; if(q2>high) { high = q2; } if(q3>high) { high = q3; } if(q4>high) { high = q4; } low = q1; if(q2<low) { low = q2; } if(q3<low) { low = q3; } if(q4<low) { low = q4; } } void grading(double avg, char& grd) { if (avg>96.3) grd = 'A'; else if (avg>=80) grd = 'B'; else if (avg>=70) grd = 'C'; else if (avg>=60) grd = 'D'; else grd = 'F'; } void avgQ(double q,double& Total,int& count) { Total += q; if (q != 0) { count++; } } void printStudentQuiz(int quiz) { if (quiz == 0) cout << ' '; else cout << quiz; cout << setw(6); } |
|
|
the red line pops up under equal sign. |
if you dont want to help , you can get out of this page. |