-
Notifications
You must be signed in to change notification settings - Fork 0
/
atm02.js
58 lines (58 loc) · 1.44 KB
/
atm02.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
import inquirer from "inquirer";
const answers = await inquirer.prompt([
{
type: "input",
name: "userId",
message: "kindly Enter Your Id:"
},
{
type: "number",
name: "userPin",
message: "kindly Enter Your PIN:"
},
{
type: "list",
name: "accountType",
choices: ["current", "saving"],
message: "Select Your Transaction"
},
{
type: "list",
name: "transactionType",
choices: ["Fast Cash", "Withdraw"],
message: "Select Your Transaction",
when(answers) {
return answers.accountType;
}
},
{
type: "list",
name: "amount",
choices: [5000, 10000, 15000, 20000],
message: "Select Your Amount",
when(answers) {
return answers.transactionType == "Fast Cash";
}
},
{
type: "number",
name: "amount",
message: "Enter Your Amount",
when(answers) {
return answers.transactionType == "Withdraw";
}
},
]);
if (answers.userId && answers.userPin) {
const bal = Math.floor(Math.random() * 100000);
console.log(bal);
const EnteredAmount = answers.amount;
if (bal >= EnteredAmount) {
const remianing = bal - EnteredAmount;
console.log("Your Remaining Balance is ", remianing);
}
else {
console.log("Insufficient Balance");
}
}
// console.log(answers)