-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.ts
65 lines (60 loc) · 1.7 KB
/
index.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
#!/usr/bin/env node
import inquirer from "inquirer";
console.log("Welcome to Simple Command Line ATM");
console.log("PIN number = 1234")
let balance : number = 200000;
const pin : number = 1234;
const askForPin = await inquirer.prompt(
{
name : "pinAsk",
type : "number",
message : "Enter your PIN number"
}
)
if (askForPin.pinAsk===pin){
console.log("Successfully accessed");
const Options = await inquirer.prompt(
{
name : "options",
type : "list",
message : "Select your desired option from the following:",
choices : ["Balance","Withdraw"]
}
)
if (Options.options==="Balance"){
console.log(`Your current balance is ${balance} Rupees`)
}
else if (Options.options==="Withdraw"){
const withdrawOptions = await inquirer.prompt([
{name : "options",
type : "list",
message : "Select amount to Withdraw",
choices : [1000,2000,5000,10000,"Other Amount"]
}
])
if (withdrawOptions.options==="Other Amount"){
const otherAmount = await inquirer.prompt({
name : "options",
type : "number",
message : "Enter amount : "
}
);
if (otherAmount.options>balance){
console.log("Insufficient Amount Entered")
}
else{
balance-=otherAmount.options;
console.log(`You have successfully withdraw ${otherAmount.options} Rupees`)
console.log(`Now your current balance is ${balance} Rupees`);
}
}
else{
balance-=withdrawOptions.options;
console.log(`You have successfully withdraw ${withdrawOptions.options} Rupees`)
console.log(`Now your current balance is ${balance} Rupees`);
}
}
}
else{
console.log("Incorrect PIN number")
};