-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgrade.js
More file actions
48 lines (37 loc) · 837 Bytes
/
grade.js
File metadata and controls
48 lines (37 loc) · 837 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/* finding grade of student
avg Grade
90-100 A+
80-89 A
70-79 B+
60-69 B
50-59 C
40-49 D
0-39 Fail
Note: min marks in each sub is 40
*/
//defining a function to find grade of student
function getResult()
{
let hm,cm,jm,bm,tot,avg,grd; //local variable name should not match with html id's
//data coll
hm=+html.value;
cm=+css.value;
jm=+js.value;
bm=+bs.value;
//calc's
tot=hm+cm+jm+bm;
abg=tot/4;
//checking pass or Fail
if(hm>39&&cm>39&&jm>39&&bm>39)
{
//pass
grd=avg>=90?'A+':avg>=80?'A':avg>=70?'B+':avg>=60?'B':avg>=50?'C':'D';
}
else{
grd='Fail';
}
//displaying op's
total.value="Total Marks :"+tot;
average.value="Average :"+avg;
grade.value="Grade :"+grd;
}