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
|
//A college tool for analysing students marks, group according to levels and
//calculation of percentage pass and fail.
#include <iostream>
using namespace std;
int main()
{
double average, mark,p_Fail, p_Pass, numWrote, numPass, numFail, sumMarks;
int level1, level2, level3, level4, level5, level6, level7;
level1 = level2 = level3 = level4 = level5 = level6 = level7 = 0;
while (mark != -1) {
sumMarks += mark;
++numWrote;
cout << "Enter a mark: "; // Enter marks to be processed.
cin >> mark;
if ((mark >= 0) && (mark <= 29)) { // Group marks according to their levels
++level1;
}
else if ((mark >=30) && (mark <= 39)) {
++level2;
}
else if ((mark >=40) && (mark <= 49)) {
++level3;
}
else if ((mark >=50) && (mark <= 59)) {
++level4;
}
else if ((mark >=60) && (mark <= 69)) {
++level5;
}
else if ((mark >=70) && (mark <= 79)) {
++level6;
}
else if ((mark >=80) && (mark <= 100)) {
++level7;
}
}
average = sumMarks / numWrote;
numPass = level4 + level5 + level6 + level7;
numFail = level1 + level2 + level3;
p_Pass = (numPass/numWrote)*100.0;
p_Fail = (numFail/numWrote)*100.0;
cout << "The average grade is: " << average << endl; //
cout << "Number wrote = "<<" "<< numWrote<<endl;
cout << "Number passed ="<<" "<< numPass <<endl;
cout << "Number failed ="<<" "<< numFail <<endl;
cout << "Percentage Pass ="<<" "<< p_Pass <<endl;
cout << "Percentage fail ="<<" "<< p_Fail <<endl;
cout << "Number in level 1 ="<<" "<<level1<< endl;
cout << "Number in level 2 ="<<" "<<level2<< endl;
cout << "Number in level 3 ="<<" "<<level3<< endl;
cout << "Number in level 4 ="<<" "<<level4<< endl;
cout << "Number in level 5 ="<<" "<<level5<< endl;
cout << "Number in level 6 ="<<" "<<level6<< endl;
cout << "Number in level 7 ="<<" "<<level7<< endl;
return 0;
}
|