-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathatm_machine.ts
81 lines (67 loc) · 2.37 KB
/
atm_machine.ts
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
#! /usr/bin/env node
import inquirer from "inquirer";
console.log("\n This ATM Machine Is Built By Fazilat Jahan \n")
let myBalance = 4500
let myPincode = 1010
let pin= await inquirer.prompt([{
name: "PinNumber",
type: "number",
message: "Please Enter Your Pin Code",
}]);
if (pin.PinNumber == myPincode) {
console.log("\n Correct Pin Code \n")
let options = await inquirer.prompt([{
name: "selection",
message: "Please Select Options",
type: "list",
choices : ["Withdraw", "Fast Cash" , "Check Balance"]
}]);
console.log("\n")
if (options.selection == "Withdraw"){
let money = await inquirer.prompt({
name: "amount",
type: "number",
message: "Please Enter Your Amount For Withdraw"
});
if (money.amount > myBalance ) {
console.log("\n Insufficient Amount \n")
} else {
myBalance -= money.amount
console.log(`\n Thanks for Withdrawal. \n Now Your Current Balance Is ${myBalance}\n`) }
}
else if (options.selection == "Fast Cash"){
let cash = await inquirer.prompt({
name: "cash",
type: "list",
message: "Please Select",
choices: ["500" ,"1000", "5000"]
})
if (cash.cash == "500"){
if (cash.cash > myBalance) {
console.log("\n Insufficient Amount \n")
} else {
myBalance -= cash.cash
console.log(`\n Thanks for Withdrawal. \n Now Your Current Balance Is ${myBalance}\n `) }
}
else if (cash.cash == "1000"){
if (cash.cash > myBalance) {
console.log("\n Insufficient Amount\n")
} else {
myBalance -= cash.cash
console.log(`\n Thanks for Withdrawal. \n Now Your Current Balance Is ${myBalance}\n`) }
}
else if (cash.cash == "5000"){
if (cash.cash > myBalance) {
console.log("\n Insufficient Amount \n")
} else {
myBalance -= cash.cash
console.log(`\n Thanks for Withdrawal. \n Now Your Current Balance Is ${myBalance}\n`) }
}
}
else if (options.selection == "Check Balance"){
console.log(` Your Current Balance Is ${myBalance}\n`)
}
}
else{
console.log("\n Incorrect Pin Number \n")
}