-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.ts
83 lines (70 loc) · 2.1 KB
/
main.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
82
83
#! /usr/bin/env node
import inquirer from "inquirer";
//make a variable of of my current amount in account....
let myBalance = 20000;
//make a variable in which i store my atm pin
let myPin = 2343;
//now i make prompt in which user enter atm pin
let pinAnswer = await inquirer.prompt({
name: "Pin",
message: "Enter your Pin",
type: "number",
});
//if user enter right pin then print a message where user select option
if (pinAnswer.Pin === myPin) {
console.log("correct pin code");
let operationAns = await inquirer.prompt(
[
{
name: "operation",
message: "Please select option",
type: "list",
choices: ["withdraw","Fast cash", "check balance"],
},
]
);
//if user select withdraw option
if (operationAns.operation === "withdraw") {
let amountAns = await inquirer.prompt(
[
{
name: "amount",
message: "Enter Your Amount",
type: "number",
}
]
);
// if user enter amount for withdraw then subtract their amount from currrent balance and show remaining balance
if (amountAns.amount <= myBalance) {
let balance = myBalance - amountAns.amount;
console.log(`The remaining Balance is ${balance}`);
}
//if user enter greater amount than their available balance then print statment of insufficient balance
else {
console.log(`You Have Insufficient Balance`);
}
}
// if user select fast cash options
else if (operationAns.operation === "Fast cash") {
let FastcashAns = await inquirer.prompt({
name: "amount",
type: "list",
choices: ["1000", "5000", "10000", "25000"],
});
if (FastcashAns.amount <= myBalance) {
let balance2 = myBalance - FastcashAns.amount;
console.log(`The remaining Balance is ${balance2}`);
}
else{
console.log(`You Have Insufficient Balance`);
}
}
// if user enter greater amount than current balance
else if (operationAns.operation === "check balance") {
console.log(`Your current Balance is ${myBalance}`);
}
}
//if user enter wrong pin .......
else {
console.log("Invalid pin code");
}