Calculate a Student's average score for a course with 4 quizzes, 2 midterms
and a final. The quizzes are weighted 30%, the midterm 40% and the final 30%
Source Code:
Output:
and a final. The quizzes are weighted 30%, the midterm 40% and the final 30%
Source Code:
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 | #include <iostream.h> #include <iomanip.h> #include <conio.h> const int cQuizWeight = 30; const int cMidtermWeight = 40; const int cFinalWeight = 30; const float cQuizMax = 400.00; const float cMidtermMax = 200.00; const float cFinalMax = 100.00; int main () { cout << " =========== QUIZZES ============ \n"; cout << " Enter the score for the First quiz: "; int quiz1; cin >> quiz1; cout << " Enter the score for the Second quiz: "; int quiz2; cin >> quiz2; cout << " Enter the score for the Third quiz: "; int quiz3; cin >> quiz3; cout << " Enter the score for the Fourth quiz: "; int quiz4; cin >> quiz4; cout << "\n =========== MIDTERM ============ \n"; cout << " Enter the score for the First midterm: "; int midterm1; cin >> midterm1; cout << " Enter the score for the Second midterm: "; int midterm2; cin >> midterm2; cout << "\n =========== FINAL ============ \n"; cout << " Enter the score for the Final: "; int final; cin >> final; cout << endl ; int totalQuiz = quiz1 + quiz2 + quiz3 + quiz4 ; int totalMidterm = midterm1 + midterm2 ; float quizPercent = static_cast<float> (totalQuiz * cQuizWeight) / cQuizMax; float midtermPercent= static_cast<float> (totalMidterm * cMidtermWeight) / cMidtermMax; float finalPercent = static_cast<float> (final * cFinalWeight) / cFinalMax; float totalPercent = quizPercent + midtermPercent + finalPercent; cout << fixed; cout << showpoint; cout << setprecision(1); cout << " First Quiz " << setw(3) << quiz1 << endl; cout << " Second Quiz " << setw(3) << quiz2 << endl; cout << " Third Quiz " << setw(3) << quiz3 << endl; cout << " Fourth Quiz " << setw(3) << quiz4 << endl; cout << " Total Quiz " << setw(3) << totalQuiz << endl << endl; cout << " First Midterm " << setw(3) << midterm1 << endl; cout << " Second Midterm " << setw(3) << midterm2 << endl; cout << " Total Midterm " << setw(3) << totalMidterm << endl << endl; cout << " Final " << setw(3) << final << endl << endl; cout << " Quiz " << setw(6) << quizPercent << "%\n"; cout << " Midterm " << setw(6) << midtermPercent << "%\n"; cout << " Final " << setw(6) << finalPercent << "%\n"; cout << " ------------------\n"; cout << " Total " << setw(6) << totalPercent << "%\n"; getch(); return 0; } // main |
Output:
=========== QUIZZES ============ Enter the score for the First quiz: 98 Enter the score for the Second quiz: 89 Enter the score for the Third quiz: 78 Enter the score for the Fourth quiz: 79 =========== MIDTERM ============ Enter the score for the First midterm: 90 Enter the score for the Second midterm: 100 =========== FINAL ============ Enter the score for the Final: 92 First Quiz 98 Second Quiz 89 Third Quiz 78 Fourth Quiz 79 Total Quiz 344 First Midterm 90 Second Midterm 100 Total Midterm 190 Final 92 Quiz 25.8% Midterm 38.0% Final 27.6% ------------------ Total 91.4%
No comments:
Post a Comment