-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
94 lines (63 loc) · 1.37 KB
/
Copy pathmain.js
File metadata and controls
94 lines (63 loc) · 1.37 KB
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
// calculator logic:
let num = 10;
let num2 = 0;
let operator = '/';
if (operator === '+'){
console.log(num + num2);
}
else if (operator === '-'){
console.log(num - num2);
}
else if (operator === '*'){
console.log(num * num2);
}
else if (operator === '/'){
if(num2 !=0){
console.log(num / num2)}
else {
console.log("num2 cannot be zero");
}
}
else {
console.log("invalid operator");
}
// -------------------------------------------------------
// student mark analysis:
let mark =30; // set the student mark
let bonus = 4;
mark += bonus; // adding mark by bonus using assignment operator
let grade; // set the grade using by mark
if (mark >= 90){
grade = "A";
}
else if(mark >= 70){
grade = "B";
}
else if(mark >= 50){
grade = "C";
}
else{
grade = "F";
}
// get the mark result of student ,pass or fail using terenory operator
let result = mark >= 50 ? "pass" : "fail";
// set the remarks using switch statement
let remarks;
switch (grade){
case "A":
remarks = "excellent";
break;
case "B":
remarks = "good";
break;
case "C":
remarks = "average";
break;
default:
remarks = "Needs Improvement";
}
// Print results
console.log("Marks:", mark);
console.log("Grade:", grade);
console.log("Result:", result);
console.log("Remark:", remarks);