-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
98 lines (98 loc) · 4.37 KB
/
main.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
#! /usr/bin/env node
import chalk from "chalk";
import inquirer from "inquirer";
let mybalance = 0;
console.log(chalk.cyanBright(" -------------------------------- "));
console.log(chalk.cyanBright(" | WELCOME TO INSTITUTE OF MOIZ | "));
console.log(chalk.cyanBright(" -------------------------------- "));
const studentId = Math.floor(10000 + Math.random() * 90000);
let question = await inquirer.prompt({
name: "q1",
message: chalk.italic.cyanBright("ASALAMUALIKUM SIR!\n ARE YOUR HERE TO BE ENROLL"),
type: "confirm",
default: true
});
console.log(chalk.green(question.q1));
console.log(chalk.italic.cyanBright("\n STUDENT ID:"), chalk.underline.yellowBright(studentId));
let answer = await inquirer.prompt([
{
name: "student",
message: chalk.italic.cyanBright("ENTER STUDENT NAME"),
type: "input",
validate: function (value) {
if (value.trim() !== "")
return true;
return chalk.underline.red("PLEASE ENTER VALID NAME!!");
},
},
{
name: "courses",
message: chalk.italic.cyanBright("SELECT THE COURSE YOU WANT TO ENROLL."),
type: "list",
choices: ["Typescript", "Python", "Php", "Html", "Css", "GraphicDesigner"]
}
]);
console.log(chalk.italic.cyanBright("\nSTUDENT NAME:"), chalk.underline.yellowBright(answer.student));
console.log(chalk.italic.cyanBright("\nYOUR SELECTED COURSE IS:"), chalk.underline.yellowBright(answer.courses));
const tutionFee = {
"Typescript": 20000,
"Python": 25500,
"Php": 25000,
"Html": 15000,
"Css": 8000,
"GraphicDesigner": 27500
};
console.log(chalk.italic.cyanBright("\n TUTION FEES:"), `${tutionFee[answer.courses]}`);
;
console.log(chalk.italic.cyanBright("BALANCE:"), chalk.underline.yellowBright(mybalance));
let paymentMethod = await inquirer.prompt([
{
name: "payment",
message: chalk.italic.cyanBright("\nWHICH PAYMENT METHOD YOU WOULD LIKE TO SELECT.\n"),
type: "list",
choices: [chalk.underline("Meezan Bank"), chalk.underline("AL-Habib"), chalk.underline("Islamic Bank"), chalk.underline("NBP"), chalk.underline("Alied Bank")]
},
{
name: "amount",
message: chalk.italic.cyanBright("\n TRANSFER THE SELECTED COURSE FEES.\n"),
type: "input",
validate: function (value) {
if ((value) != "")
return true;
return chalk.underline.red("PLEASE ENTER VALID AMOUNT");
}
}
]);
console.log(chalk.italic.cyanBright("\nYOUR SELECTED PAYMENT MEHTOD IS:"), chalk.underline.yellowBright(paymentMethod.payment), chalk.italic.cyanBright("\n FEES COLLECTED:"), chalk.underline.yellowBright(paymentMethod.amount));
const tutionFees = tutionFee[answer.courses];
const paymentAmount = parseFloat(paymentMethod.amount);
if (tutionFees === paymentAmount) {
console.log(chalk.italic.cyanBright(` CONGRATULATIONS! YOUR ARE ENROLLED TO OUR ${chalk.underline.yellowBright(answer.courses)} COURSE.`));
}
else {
console.log(chalk.underline.red("\n INVALID AMOUNT DUE TO COURSE "));
}
;
let studentAns = await inquirer.prompt([
{
name: "operation",
message: chalk.italic.cyanBright("\n WHAT WOULD YOU LIKE TO DO NOW? "),
type: "list",
choices: [chalk.underline("View Status"), chalk.underline("Exit")]
}
]);
if (studentAns.operation === chalk.underline("View Status")) {
console.log(chalk.underline.magentaBright("\n | STATUS | "));
console.log(chalk.italic.cyan(`STUDENT NAME:${chalk.underline.yellowBright(answer.student)}`));
console.log(chalk.italic.cyan(`STUDENT ID:${chalk.underline.yellowBright(studentId)}`));
console.log(chalk.italic.cyan(`COURSE NAME:${chalk.underline.yellowBright(answer.courses)}`));
console.log(chalk.italic.cyan(`FEES PAID:${chalk.underline.yellowBright(tutionFees)}`));
console.log(chalk.italic.cyan(`BALANCE:${chalk.underline.yellowBright(mybalance += paymentAmount)}`));
}
else {
console.log(chalk.italic.magentaBright("\n | EXITING THE STUDENT MANAGEMENT SYSTEM. | "));
}
;
console.log(chalk.cyanBright(" --------------------------------------- "));
console.log(chalk.cyanBright(" |THANK YOU FOR COMING MOIZ's INSTITUTE| "));
console.log(chalk.cyanBright(" --------------------------------------- "));