Created
July 1, 2024 14:16
-
-
Save sethmwebi/ec3fc784ecf948cf113ba33a4f8af8e7 to your computer and use it in GitHub Desktop.
This file contains 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
const r1 = require("readline").createInterface({ | |
input: process.stdin, | |
output: process.stdout, | |
}); | |
function awardGrades(score) { | |
if (score > 79) { | |
return "A"; | |
} else if (score >= 60 && score <= 79) { | |
return "B"; | |
} else if (score >= 50 && score <= 59) { | |
return "C"; | |
} else if (score >= 40 && score <= 49) { | |
return "D"; | |
} else { | |
return "E"; | |
} | |
} | |
r1.question("Enter student marks: ", function (input) { | |
const mark = Number(input); | |
if (isNaN(mark) || mark > 100 || mark < 0) { | |
console.log("The marks you entered is not correct"); | |
} else { | |
let grade = awardGrades(mark); | |
console.log("The grade is " + grade); | |
} | |
r1.close(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment