-
Notifications
You must be signed in to change notification settings - Fork 0
/
atm.ts
64 lines (62 loc) · 1.46 KB
/
atm.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
import inquirer from "inquirer";
interface ansType{
userID:string,
userPIN:number,
accountType:string,
transactionType:string,
amount:number
}
const answers:ansType=await inquirer.prompt([{
type:"input",
name:"userID",
message:"Kindly enter your User ID:"
},
{
type:"number",
name:"userPIN",
message:"Kindly enter your User PIN:"
},
{
type:"list",
name:"accountType",
choices:["Current","Savings"],
message:"Select your Account Type:"
},
{
type:"list",
name:"transactionType",
choices:["Fast Cash","Withdraw"],
message:"Select your transaction",
when(answers:any){
return answers.accountType
}
},
{
type:"list",
name:"amount",
choices:["1000","2000","5000","10000","20000"],
message:"Select your Amount",
when(answers:any){
return answers.transactionType ==="Fast Cash"
}
},
{
type:"number",
name:"amount",
message:"Enter your Amount",
when(answers:any){
return answers.transactionType=="Withdraw"
},
}
])
if (answers.userID && answers.userPIN){
const balance =Math.floor(Math.random()*10000000);
console.log(balance)
const EnteredAmount=answers.amount;
if (balance > EnteredAmount){
const remaining=balance - EnteredAmount;
console.log("Your remaining balance is", remaining)
} else {
console.log("Insufficient Balance!")
}
};