-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
68 lines (68 loc) · 1.82 KB
/
index.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
#! /usr/bin/env node
import inquirer from "inquirer";
// Asking for roll number
let roll = await inquirer.prompt({
type: "number",
name: "num1",
message: "Please enter your roll number:"
});
// rollnumber
let rollNumber = roll.num1;
// checking rollnumber
if (rollNumber === 456789) {
// Asking for marks
let marks = await inquirer.prompt([
{
name: "typescript",
type: "number",
message: "Please enter your typescript number:",
},
{
name: "python",
type: "number",
message: "Please enter your python number:",
},
{
name: "csharp",
type: "number",
message: "Please enter your csharp number:",
}
]);
// extract marks
let ts = marks.typescript;
let pyth = marks.python;
let c_sharp = marks.csharp;
// percentage
let totalMarks = 300;
let obtainMarks = ts + pyth + c_sharp;
let percentage = ((obtainMarks / totalMarks) * 100);
// Answer
console.log("Name: Ali");
console.log("Father Name: Hassan");
console.log(`Typescript Marks = ${ts}out of 100`);
console.log(`python Marks = ${pyth}out of 100`);
console.log(`csharp Marks = ${c_sharp}out of 100`);
console.log(`Obtain Marks = ${obtainMarks} Total Marks = ${totalMarks}`);
console.log(`Percentage = ${percentage}%`);
if (percentage >= 80) {
console.log("Grade A+");
}
else if (percentage >= 70) {
console.log("Grade A");
}
else if (percentage >= 60) {
console.log("Grade B");
}
else if (percentage >= 50) {
console.log("Grade C");
}
else if (percentage >= 45) {
console.log("Grade D");
}
else {
console.log("You are Fail!!");
}
}
else {
console.log(`Invalid Wrong Number`);
}