-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
62 lines (62 loc) · 1.84 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
#! /usr/bin/env node
import inquirer from "inquirer";
let totalBalance = 10000;
let pinNumber = 1234;
let pinEntered = await inquirer.prompt([
{
name: "pin",
message: "Enter Your 4 Digit Pin Code",
type: "number"
}
]);
if (pinEntered.pin === pinNumber) {
console.log("Correct Pin Code");
let atmQuestion = await inquirer.prompt([
{
name: "accountType",
message: "Please Select Account Type",
type: "list",
choices: ["Current Account", "Saving Account"]
},
{
name: "transMethod",
message: "Select Your Transcation Method",
type: "list",
choices: ["Cash Withdrawal", "Fast Cash"]
}
]);
console.log(atmQuestion);
if (atmQuestion.transMethod === "Cash Withdrawal") {
let cashwithdrawAmount = await inquirer.prompt([
{
name: "withdrawal",
message: "Enter Your Amount To Withdraw",
type: "number"
}
]);
if (totalBalance >= cashwithdrawAmount.withdrawal) {
totalBalance -= cashwithdrawAmount.withdrawal;
console.log(`Your Balance is ${totalBalance}`);
}
else {
console.log("Insufficent Balance");
}
}
else {
let fastcashAmount = await inquirer.prompt([
{
name: "fastCash",
message: "Select The Amount You Want To Withdraw",
type: "list",
choices: ["1000", "3000", "5000"]
}
]);
if (totalBalance >= fastcashAmount.fastCash) {
totalBalance -= fastcashAmount.fastCash;
console.log(`Your Total Balance Is ${totalBalance}`);
}
else {
console.log("Insufficient Balance");
}
}
}