-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfindGrades01.js
112 lines (100 loc) · 2.61 KB
/
findGrades01.js
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
/*
You and your friends Tom, Jane, Peter and John got their final exam results. Your total score is 85, Tom's total score is 66, Jane's total score is 95, Peter's total score is 56 amd john's total score is 40.
The grading chart is -
80 or above A grade,
60 or above B grade,
50 or above C grade,
40 or above D grade and
39 or above => F grade.
Write a program to find your and your friends' grades using 'if-else'.
*/
var totalScoreMyself = 85;
var totalScoreTom = 66;
var totalScoreJane = 95;
var totalScorePeter = 56;
var totalScoreJohn = 40;
// Calculating my grade
if (totalScoreMyself >= 80) {
console.log("You have got 'A' grade");
}
else if (totalScoreMyself >= 60) {
console.log("You have got 'B' grade");
}
else if (totalScoreMyself >= 50) {
console.log("You have got 'C' grade");
}
else if (totalScoreMyself >= 40) {
console.log("You have got 'D' grade");
}
else {
console.log("You have got 'F' grade");
}
// Output || You have got 'A' grade
// Calculating Tom's grade
if (totalScoreTom >= 80) {
console.log("Tom has got 'A' grade");
}
else if (totalScoreTom >= 60) {
console.log("Tom has got 'B' grade");
}
else if (totalScoreTom >= 50) {
console.log("Tom has got 'C' grade");
}
else if (totalScoreTom >= 40) {
console.log("Tom has got 'D' grade");
}
else {
console.log("Tom has got 'F' grade");
}
// Output || Tom has got 'B' grade
// Calculating Jane's grade
if (totalScoreJane >= 80) {
console.log("Jane has got 'A' grade");
}
else if (totalScoreJane >= 60) {
console.log("Jane has got 'B' grade");
}
else if (totalScoreJane >= 50) {
console.log("Jane has got 'C' grade");
}
else if (totalScoreJane >= 40) {
console.log("Jane has got 'D' grade");
}
else {
console.log("Jane has got 'F' grade");
}
// Output || Jane has got 'A' grade
// Calculating Peter's grade
if (totalScorePeter >= 80) {
console.log("Peter has got 'A' grade");
}
else if (totalScorePeter >= 60) {
console.log("Peter has got 'B' grade");
}
else if (totalScorePeter >= 50) {
console.log("Peter has got 'C' grade");
}
else if (totalScorePeter >= 40) {
console.log("Peter has got 'D' grade");
}
else {
console.log("Peter has got 'F' grade");
}
// Output || Peter has got 'C' grade
// Calculating John's grade
if (totalScoreJohn >= 80) {
console.log("John has got 'A' grade");
}
else if (totalScoreJohn >= 60) {
console.log("John has got 'B' grade");
}
else if (totalScoreJohn >= 50) {
console.log("John has got 'C' grade");
}
else if (totalScoreJohn >= 40) {
console.log("John has got 'D' grade");
}
else {
console.log("John has got 'F' grade");
}
// Output || John has got 'D' grade