-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBanking app in js.txt
More file actions
163 lines (125 loc) · 5.57 KB
/
Banking app in js.txt
File metadata and controls
163 lines (125 loc) · 5.57 KB
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
Que : Develop a 'JavaScript' program that simulates a simple bank account system. Users can create accounts, deposit money, withdraw money, and check their balances. Implement separate functions for these operations. Take the initial balance as Rs.2000.
--------
-> create a function bankApplication()
-> parameters : none
-> no return
-> this will be your main function. from this function only your bank application will start this function display bank menu to the user and based on the users choice it will execute the rest of the functions.
-> when user chooses 5 as exit it will display a message " Thank you for banking with us " and stops the program.
-> when user chooses the 1 as create account it will prompt user to enter account number then it will call createAccount() function for next execution.
-> validations :
-> validate the user input either he chooses the option from 1-5 only otherwise alert user "invalid option" and call bankApplication() again.
-> validate the accountNumber that user enters only numeric value.
-> create a createAccount() function
-> parameters : none
-> no return
-> this function will prompt the user to enter the initial amount to open a bank account.
-> validations :
-> validate that the initial amount is non-negative and non-zero alert user " enter valid amount " if user enter negative or zero and call createAccount() again.
-> validate that the user enter amount > 2000 otherwise alert user " the initial amount is minimum 2000 " and call createAccount() again.
-> on success it will alert user " your account is created successfully, your account number is ${accountNumber} "
-> create a function depositeMoney()
-> parameters : none
-> no return
-> this function will prompt the user to " enter amount to deposit " to deposit money into account.
-> Validations:
-> validate that while user chooses this option the account number is not 0 otherwise alert user " please create account first " and call bankApplication().
-> validate that the deposit amount is non-negative and non-zero alert user " Invalid amount to deposit " if user enter negative or zero and call depositeMoney() again.
-> on success it will alert user " Rs. ${amt} deposited successfully. Your current balance is: Rs. ${amount} "
-> create a function withdraw()
-> parameters : none
-> no return
-> this function will prompt the user to " enter amount to withdraw " to withdraw a money from account.
-> Validations:
-> validate that while user chooses this option the account number is not 0 otherwise alert user " please create account first " and call bankApplication().
-> validate that the withdrawal amount is non-negative and non-zero alert user " Invalid amount to withdraw " if user enter negative or zero and call withdraw() again.
-> validate that the intial amount 2000 is fixed user cannot withdraw the money when it is 2000 if user enter the amt greater than initial balance or user entered
(amt-balance) is less than 2000 alert user "Insufficient Funds"
-> on success it will alert user " Rs. ${amt} withdrawn successfully. Your current balance is: Rs. ${amount} "
-> create a function checkBalance()
-> parameters : none
-> no return
-> this function will alert user " account number ${accountNumber} total balance ${amount}.
-> Validations:
-> validate that while user chooses this option the account number is not 0 otherwise alert user " please create account first " and call bankApplication().
-> on success it will display "Your current balance is: Rs. ${amount}"
SAMPLE INPUT AND SAMPLE OUTPUT :
--------------------------------
--- Bank Account Menu ---
1. Create Account
2. Deposit Money
3. Withdraw Money
4. Check Balance
5. Exit
Enter your choice: 1
your account is created successfully, your account number is ${accountNumber}
-------------------------------------------------------
--- Bank Account Menu ---
1. Create Account
2. Deposit Money
3. Withdraw Money
4. Check Balance
5. Exit
Enter your choice: 2
Enter amount to deposit: 1500
Rs. 1500 deposited successfully.
Your current balance is: Rs. 3500
-------------------------------------------------------
--- Bank Account Menu ---
1. Create Account
2. Deposit Money
3. Withdraw Money
4. Check Balance
5. Exit
Enter your choice: 2
Enter amount to deposit: -500
Invalid amount to deposit
-------------------------------------------------------
--- Bank Account Menu ---
1. Create Account
2. Deposit Money
3. Withdraw Money
4. Check Balance
5. Exit
Enter your choice: 3
Enter amount to withdraw: 1000
Rs. 1000 withdrawn successfully.
Your current balance is: Rs. 2500
-------------------------------------------------------
--- Bank Account Menu ---
1. Create Account
2. Deposit Money
3. Withdraw Money
4. Check Balance
5. Exit
Enter your choice: 3
Enter amount to withdraw: -300
Invalid amount to withdraw
-------------------------------------------------------
--- Bank Account Menu ---
1. Create Account
2. Deposit Money
3. Withdraw Money
4. Check Balance
5. Exit
Enter your choice: 3
Enter amount to withdraw: 3000
Insufficient Funds
-------------------------------------------------------
--- Bank Account Menu ---
1. Create Account
2. Deposit Money
3. Withdraw Money
4. Check Balance
5. Exit
Enter your choice: 4
Your current balance is: Rs. 2500
-------------------------------------------------------
--- Bank Account Menu ---
1. Create Account
2. Deposit Money
3. Withdraw Money
4. Check Balance
5. Exit
Enter your choice: 5
Thank you for banking with us.
===========================================================================================================================