I'm trying to make a grade calculator using js, but facing some issue to implement conditions in my project. (check out my code) I have chosen 5 subjects to calculate the GPA and successfully implemented these things. ( 1. Total Marks obtained out of 500, 2. Percentage, 3. Grade point 4. Grade) but unable to implement the final one pass/fail decision. According to my current code, when someone's calculated percentage is less than 33, it is considered as failed. or if greater than or equal to 33% it is considered as pass. I want to change this condition with this one > (when any one enters less than 33 marks of any subject, they have to be consider as failed). FOR BETTER UNDERSTANDING PLEASE CHECK THE EXAMPLE:
EXAMPLE >
When anyone enters these values (Marks):
Subject1: 36, subject2: 31, subject3: 35, subject4: 30, subject5: 38,
OUTPUT: Out of 500 your total is 170 and percentage is 34.00%. Your grade point is 3.6 & Grade is D. You are Pass in 3 subject & failed in 2 subject.
Help me to implement this idea ("You are Pass in 3 subject & failed in 2 subject")
const calcy = () =>{
let sb1 = document.getElementById('sb1').value;
let sb2 = document.getElementById('sb2').value;
let sb3 = document.getElementById('sb3').value;
let sb4 = document.getElementById('sb4').value;
let sb5 = document.getElementById('sb5').value;
let grades = "";
let totalGrades = parseFloat(sb1) + parseFloat(sb2) + parseFloat(sb3) + parseFloat(sb4) + parseFloat(sb5);
let perc = (totalGrades/500*100).toFixed(2);
let gp = (perc/9.5).toFixed(1);
if(perc <= 100 && perc >= 95){
grades = ("10 & Grade is A1");
}else if(perc <= 95 && perc >= 91){
grades = gp.concat(" & Grade is A1");
}else if(perc <= 90 && perc >= 81){
grades = gp.concat(" & Grade is A2");
}else if(perc <= 80 && perc >= 71){
grades = gp.concat(" & Grade is B1");
}else if(perc <= 70 && perc >= 61){
grades = gp.concat(" & Grade is B2")
}else if(perc <= 60 && perc >= 51){
grades = gp.concat(" & Grade is C1");
}else if(perc <= 50 && perc >= 41){
grades = gp.concat(" & Grade is C2");
}else if(perc <= 40 && perc >= 33){
grades = gp.concat(" & Grade is D");
}else if(perc <= 32 && perc >= 21){
grades = gp.concat(" & Grade is E1");
}else if(perc <= 20 && perc >= 00){
grades = gp.concat(" & Grade is E2");
}
if(perc <= 100 && perc >= 91){
document.getElementById('showData').innerHTML = ` Out of 500 your total is ${totalGrades} and percentage is ${perc}%. <br> Your grade point is ${grades}, You are Pass. `
}
else if (perc <= 90 && perc >= 81){
document.getElementById('showData').innerHTML = ` Out of 500 your total is ${totalGrades} and percentage is ${perc}%. <br> Your grade point is ${grades}. You are Pass. `
}
else if (perc <= 80 && perc >= 71){
document.getElementById('showData').innerHTML = ` Out of 500 your total is ${totalGrades} and percentage is ${perc}%. <br> Your grade point is ${grades}. You are Pass. `
}
else if (perc <= 70 && perc >= 61){
document.getElementById('showData').innerHTML = ` Out of 500 your total is ${totalGrades} and percentage is ${perc}%. <br> Your grade point is ${grades}. You are Pass. `
}
else if (perc <= 60 && perc >= 51){
document.getElementById('showData').innerHTML = ` Out of 500 your total is ${totalGrades} and percentage is ${perc}%. <br> Your grade point is ${grades}. You are Pass. `
}
else if (perc <= 50 && perc >= 41){
document.getElementById('showData').innerHTML = ` Out of 500 your total is ${totalGrades} and percentage is ${perc}%. <br> Your grade point is ${grades}. You are Pass. `
}
else if (perc <= 40 && perc >= 33){
document.getElementById('showData').innerHTML = ` Out of 500 your total is ${totalGrades} and percentage is ${perc}%. <br> Your grade point is ${grades}. You are Pass. `
}
else if (perc <= 32 && perc >= 21){
document.getElementById('showData').innerHTML = ` Out of 500 your total is ${totalGrades} and percentage is ${perc}%. <br> Your grade point is ${grades}. You are Fail. `
}
else if(perc <= 20 && perc >= 00)
document.getElementById('showData').innerHTML = ` Out of 500 your total is ${totalGrades} and percentage is ${perc}%. <br> Your grade point is ${grades}. You are Fail. `
}
<div class="app-form">
<div class="app-form-group">
<input maxlength="3" type="text" class="app-form-control" placeholder="SUBJECT 1" id="sb1">
</div>
<div class="app-form-group">
<input maxlength="3" type="text" class="app-form-control" placeholder="SUBJECT 2" id="sb2">
</div>
<div class="app-form-group">
<input maxlength="3" type="text" class="app-form-control" placeholder="SUBJECT 3" id="sb3">
</div>
<div class="app-form-group">
<input maxlength="3" type="text" class="app-form-control" placeholder="SUBJECT 4" id="sb4" >
</div>
<div class="app-form-group">
<input maxlength="3" type="text" class="app-form-control" placeholder="SUBJECT 5" id="sb5" >
</div>
<div >
<input type="button" name="" value="CALCULATE CGPA" class="app-form-button" onclick="calcy()">
</div>
</div>
<div class="app-form-group showdata">
<p id="showData" > </p>
</div>