About project
ATM Simulator project is written in Python. The project file contains a python script (atm.py). This is a simple console based system which is very easy to use. Talking about the system, it contains various functions which include Account Statement, Withdrawing, Depositing amount and changing the pin. Here, at first the user has to enter an existing username, when the username matches the system proceed toward the next procedure i.e asking pin number. When a user passes all these sign-in procedures, he/she can use all those features. It is too easy to use, he/she can check their respective account statements.While depositing or withdrawing amount, he/she just has to enter the amount then the system calculates the total remaining balance of the respective account and displays to the user. And the user can view all these transactions from the account statement. In this ATM Simulator, the user can also change the pin number. For this, the user has to enter the New pin code and then confirm it in order to change the pin code. This simple console based ATM simulator provides the simple account balance management of a respective account. It contains all the essential features. There is no database connection or neither any external text or other files used in this mini project to save user’s data. Everything is set inside the source code whether its pin code or the amount.
Features
Features:
- Sign In
- Account Statement
- Withdraw amount
- Lodge amount
- Change Pin
Source Code
#!/usr/bin/python
import getpass
import string
import os
# creatinga lists of users, their PINs and bank statements
users = [‘user’, ‘user2’, ‘user3’]
pins = [‘1234’, ‘2222’, ‘3333’]
amounts = [1000, 2000, 3000]
count = 0
# while loop checks existance of the enterd username
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 = str(getpass.getpass(‘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) \nLodgement__(L) \nChange PIN_(P) \nQuit_______(Q) \n: ‘).lower()
print(‘*******************************’)
print(‘——————————-‘)
valid_responses = [‘s’, ‘w’, ‘l’, ‘p’, ‘q’]
response = response.lower()
if response == ‘s’:
print(‘———————————————‘)
print(‘*********************************************’)
print(str.capitalize(users[n]), ‘YOU HAVE ‘, amounts[n],’EURO 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 EURO 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], ‘EURO’)
print(‘***********************************’)
print(‘———————————–‘)
elif response == ‘l’:
print()
print(‘———————————————‘)
print(‘*********************************************’)
cash_in = int(input(‘ENTER AMOUNT YOU WANT TO LODGE: ‘))
print(‘*********************************************’)
print(‘———————————————‘)
print()
if cash_in%10 != 0:
print(‘—————————————————-‘)
print(‘****************************************************’)
print(‘AMOUNT YOU WANT TO LODGE MUST TO MATCH 10 EURO NOTES’)
print(‘****************************************************’)
print(‘—————————————————-‘)
else:
amounts[n] = amounts[n] + cash_in
print(‘—————————————-‘)
print(‘****************************************’)
print(‘YOUR NEW BALANCE IS: ‘, amounts[n], ‘EURO’)
print(‘****************************************’)
print(‘—————————————-‘)
elif response == ‘p’:
print(‘—————————–‘)
print(‘*****************************’)
new_pin = str(getpass.getpass(‘ENTER A NEW PIN: ‘))
print(‘*****************************’)
print(‘—————————–‘)
if new_pin.isdigit() and new_pin != pins[n] and len(new_pin) == 4:
print(‘——————‘)
print(‘******************’)
new_ppin = str(getpass.getpass(‘CONFIRM NEW PIN: ‘))
print(‘*******************’)
print(‘——————-‘)
if new_ppin != new_pin:
print(‘————‘)
print(‘************’)
print(‘PIN MISMATCH’)
print(‘************’)
print(‘————‘)
else:
pins[n] = new_pin
print(‘NEW PIN SAVED’)
else:
print(‘————————————-‘)
print(‘*************************************’)
print(‘ NEW PIN MUST CONSIST OF 4 DIGITS \nAND MUST BE DIFFERENT TO PREVIOUS PIN’)
print(‘*************************************’)
print(‘————————————-‘)
elif response == ‘q’:
exit()
else:
print(‘——————‘)
print(‘******************’)
print(‘RESPONSE NOT VALID’)
print(‘******************’)
print(‘——————‘)
Output
