OneCompiler

March

102
<script> // create a program that will asks for the score and number of //items of a quiz and compute the equivalent grade with //the formula grades=score/number of items * 100 items = Number (prompt(" Enter how many items in a quiz ")) score = Number (prompt(" Enter your score ")) grade = parseInt (score / items * 100 ) document.write("Grade : " + grade + "<br>" ) // Evaluate the grade and classification let rating; if (grade >= 91 && grade <= 100) { rating = "Excellent"; document.write("Rating: " + "Excellent" ) } else if (grade >= 81 && grade <= 90) { rating = "Very Good"; document.write("Rating: " + "Very Good" ) } else if (grade >= 71 && grade <= 80) { rating = "Good"; document.write("Rating: " + "Good" ) } else if (grade >= 51 && grade <= 70) { rating = "Fair"; document.write("Rating: " + "Fair" ) } else if (grade >= 0 && grade <= 50) { rating = "Poor"; document.write("Rating: " + "Poor" ) } else { rating = "Invalid"; document.write("Rating: " + "Invalid" ) } </script>