Created
December 16, 2025 05:41
-
-
Save isaacssemugenyi/04bf6dd6b21fa78d5b1d079f4ead529d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /*********************** | |
| * Simple Grading System | |
| ***********************/ | |
| let students = []; | |
| let totalProcessed = 0; | |
| function doIt( | |
| name, | |
| math, | |
| english, | |
| science, | |
| history, | |
| attendance, | |
| bonusPoints, | |
| extraCredit | |
| ) { | |
| if (name !== null) { | |
| if (math >= 0 && english >= 0 && science >= 0 && history >= 0) { | |
| if (attendance >= 0) { | |
| let total = math + english + science + history; | |
| if (attendance > 90) { | |
| total += 5; | |
| } | |
| if (bonusPoints > 0) { | |
| total = total + bonusPoints; | |
| } | |
| if (extraCredit > 0) { | |
| total = total + extraCredit; | |
| } | |
| let avg = total / 4; | |
| let grade = ""; | |
| if (avg >= 80) { | |
| grade = "A"; | |
| } else { | |
| if (avg >= 70) { | |
| grade = "B"; | |
| } else { | |
| if (avg >= 60) { | |
| grade = "C"; | |
| } else { | |
| if (avg >= 50) { | |
| grade = "D"; | |
| } else { | |
| grade = "F"; | |
| } | |
| } | |
| } | |
| } | |
| console.log("Student:", name); | |
| console.log("Average:", avg); | |
| console.log("Grade:", grade); | |
| students.push({ | |
| n: name, | |
| g: grade, | |
| a: avg | |
| }); | |
| totalProcessed++; | |
| } | |
| } | |
| } | |
| } | |
| function summary() { | |
| console.log("Total students processed:", totalProcessed); | |
| console.log("All students:", students); | |
| } | |
| // ===== Program Execution ===== | |
| doIt("Alice", 78, 85, 90, 88, 95, 3, 2); | |
| doIt("Bob", 55, 60, 58, 62, 80, 0, 1); | |
| doIt("Charlie", 40, 45, 50, 48, 70, 0, 0); | |
| summary(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # *********************** | |
| # * Simple Grading System | |
| # *********************** | |
| students = [] | |
| totalProcessed = 0 | |
| def doIt( | |
| name, | |
| math, | |
| english, | |
| science, | |
| history, | |
| attendance, | |
| bonusPoints, | |
| extraCredit | |
| ): | |
| global totalProcessed | |
| if name is not None: | |
| if math >= 0 and english >= 0 and science >= 0 and history >= 0: | |
| if attendance >= 0: | |
| total = math + english + science + history | |
| if attendance > 90: | |
| total += 5 | |
| if bonusPoints > 0: | |
| total = total + bonusPoints | |
| if extraCredit > 0: | |
| total = total + extraCredit | |
| avg = total / 4 | |
| grade = "" | |
| if avg >= 80: | |
| grade = "A" | |
| else: | |
| if avg >= 70: | |
| grade = "B" | |
| else: | |
| if avg >= 60: | |
| grade = "C" | |
| else: | |
| if avg >= 50: | |
| grade = "D" | |
| else: | |
| grade = "F" | |
| print("Student:", name) | |
| print("Average:", avg) | |
| print("Grade:", grade) | |
| students.append({ | |
| "n": name, | |
| "g": grade, | |
| "a": avg | |
| }) | |
| totalProcessed += 1 | |
| def summary(): | |
| print("Total students processed:", totalProcessed) | |
| print("All students:", students) | |
| # ===== Program Execution ===== | |
| doIt("Alice", 78, 85, 90, 88, 95, 3, 2) | |
| doIt("Bob", 55, 60, 58, 62, 80, 0, 1) | |
| doIt("Charlie", 40, 45, 50, 48, 70, 0, 0) | |
| summary() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment