JavaScript

May 26, 2023

How to find Student of Result Total, Average, Grade in JavaScript Program

Program to use Student of Result JavaScript Language


let Math = 57;
let English = 68;
let Computer = 76;
let Total;
let Percentage;
let Grade;

Total = Math + English + Computer;
console.log("Total of Student Number =", Total);

Percentage = Total / 3;
console.log("Percentage of Student Number =", Percentage.toFixed(2));

if (Percentage > 80 && Percentage <= 100) {
    console.log("Grade A+");
}
else if (Percentage > 60 && Percentage < 80) {
    console.log("Grade = A");
}
else if (Percentage > 45 && Percentage <= 60) {
    console.log("Grade = B");
}
else if (Percentage > 33 && Percentage < 45) {
    console.log("Grade = C");
}
else if (Percentage > 0 && Percentage < 33) {
    console.log("Grade = F");
}

Output


Total of Student Number = 201
Percentage of Student Number = 67.00
Grade = A

Steps Description

  1. Declare six variables Math, English, Computer, Total, Percentage and Grade
  2. Initialize six variables with value of 57, 68, 76 respectively Math=57, English=68, Computer=76, Total, Percentage and Grade
  3. Variable math, variable english and variable computer are three variables which are added with the help of addition operator.
  4. Three variables add value to total variable with the help of assignment operator
  5. Percentage = (assignment operator) variable Total / (division operator) 3;
  6. if statement Percentage > 80 && Percentage <= 100 display Grade A+
  7. else if statement Percentage > 60 && Percentage < 80 display Grade A
  8. else if statement Percentage > 45 && Percentage < 60 display Grade B
  9. else if statement Percentage > 33 && Percentage < 45 display Grade C
  10. else if statement Percentage > 0 && Percentage < 33 display Grade F
  11. console.log inbuild function to display Total variable number Percentage variable number and Grade variable alphabet

by : Suhel Akhtar

Quick Summary:

Program to use Addition ( + ) Operator Division ( / )Operator AND ( && ) Operator if statement else if statement use Student of Result Total, Average, Grade JavaScript Language