-
Notifications
You must be signed in to change notification settings - Fork 4
/
main.py
203 lines (194 loc) · 7.73 KB
/
main.py
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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
import getpass
import string
import os
# creatinga lists of users, their PINs and bank statements
users = ['user1', 'user2', 'user3']
pins = ['1234', '2222', '3333']
amounts = [1000, 2000, 3000]
count = 0
# while loop checks existance of the enterd username
print("****************************************************************************")
print("* *")
print("* Welcome to ATM MACHINE *")
print("* *")
print("****************************************************************************")
while True:
user = input('\nENTER USER NAME: ')
user = user.lower()
if user in users:
if user == users[0]:
n = 0
elif user == users[1]:
n = 1
else:
n = 2
break
else:
print('----------------')
print('****************')
print('INVALID USERNAME')
print('****************')
print('----------------')
# comparing pin
while count < 3:
print('------------------')
print('******************')
pin = input('PLEASE ENTER PIN: ')
print('******************')
print('------------------')
if pin.isdigit():
if user == 'user1':
if pin == pins[0]:
break
else:
count += 1
print('-----------')
print('***********')
print('INVALID PIN')
print('***********')
print('-----------')
print()
if user == 'user2':
if pin == pins[1]:
break
else:
count += 1
print('-----------')
print('***********')
print('INVALID PIN')
print('***********')
print('-----------')
print()
if user == 'user3':
if pin == pins[2]:
break
else:
count += 1
print('-----------')
print('***********')
print('INVALID PIN')
print('***********')
print('-----------')
print()
else:
print('------------------------')
print('************************')
print('PIN CONSISTS OF 4 DIGITS')
print('************************')
print('------------------------')
count += 1
# in case of a valid pin- continuing, or exiting
if count == 3:
print('-----------------------------------')
print('***********************************')
print('3 UNSUCCESFUL PIN ATTEMPTS, EXITING')
print('!!!!!YOUR CARD HAS BEEN LOCKED!!!!!')
print('***********************************')
print('-----------------------------------')
exit()
print('-------------------------')
print('*************************')
print('LOGIN SUCCESFUL, CONTINUE')
print('*************************')
print('-------------------------')
print()
print('--------------------------')
print('**************************')
print(str.capitalize(users[n]), 'welcome to ATM')
print('**************************')
print('----------ATM SYSTEM-----------')
# Main menu
while True:
# os.system('clear')
print('-------------------------------')
print('*******************************')
response = input(
'SELECT FROM FOLLOWING OPTIONS: \nStatement__(S) \nWithdraw___(W) \nDeposit__(D) \nChange PIN_(P) \nQuit_______(Q) \nType The Letter Of Your Choices: ').lower()
print('*******************************')
print('-------------------------------')
valid_responses = ['s', 'w', 'd', 'p', 'q']
response = response.lower()
if response == 's':
print('---------------------------------------------')
print('*********************************************')
print(str.capitalize(users[n]), 'YOU HAVE ', amounts[n], 'RUPEES ON YOUR ACCOUNT.')
print('*********************************************')
print('---------------------------------------------')
elif response == 'w':
print('---------------------------------------------')
print('*********************************************')
cash_out = int(input('ENTER AMOUNT YOU WOULD LIKE TO WITHDRAW: '))
print('*********************************************')
print('---------------------------------------------')
if cash_out % 10 != 0:
print('------------------------------------------------------')
print('******************************************************')
print('AMOUNT YOU WANT TO WITHDRAW MUST TO MATCH 10 RUPEES NOTES')
print('******************************************************')
print('------------------------------------------------------')
elif cash_out > amounts[n]:
print('-----------------------------')
print('*****************************')
print('YOU HAVE INSUFFICIENT BALANCE')
print('*****************************')
print('-----------------------------')
else:
amounts[n] = amounts[n] - cash_out
print('-----------------------------------')
print('***********************************')
print('YOUR NEW BALANCE IS: ', amounts[n], 'RUPEES')
print('***********************************')
print('-----------------------------------')
elif response == 'd':
print()
print('---------------------------------------------')
print('*********************************************')
cash_in = int(input('ENTER AMOUNT YOU WANT TO DEPOSIT: '))
print('*********************************************')
print('---------------------------------------------')
print()
if cash_in % 10 != 0:
print('----------------------------------------------------')
print('****************************************************')
print('AMOUNT YOU WANT TO LODGE MUST TO MATCH 10 RUPEES NOTES')
print('****************************************************')
print('----------------------------------------------------')
else:
amounts[n] = amounts[n] + cash_in
print('----------------------------------------')
print('****************************************')
print('YOUR NEW BALANCE IS: ', amounts[n], 'RUPEES')
print('****************************************')
print('----------------------------------------')
elif response == 'p':
print('-----------------------------')
print('*****************************')
new_pin = int(input('ENTER A NEW PIN: '))
print('*****************************')
print('-----------------------------')
print('------------------')
print('******************')
new_ppin = int(input('CONFIRM NEW PIN: '))
print('*******************')
print('-------------------')
if new_ppin != new_pin:
print('------------')
print('************')
print('PIN MISMATCH')
print('************')
print('------------')
else:
pins[n] = new_pin
print('************')
print('------------')
print('NEW PIN SAVED')
print('************')
print('------------')
elif response == 'q':
exit()
else:
print('------------------')
print('******************')
print('RESPONSE NOT VALID')
print('******************')
print('------------------')