Great Deal! Get Instant $10 FREE in Account on First Order + 10% Cashback on Every Order Order Now

A Python program that simulates an ATM. GUI interface that prompts for a User Id and PIN. The program then prompts the user to deposit, withdrawal, perform a balance inquiry or transfer between...

1 answer below »
A Python program that simulates an ATM. GUI interface that prompts for a User Id and PIN. The program then prompts the user to deposit, withdrawal, perform a balance inquiry or transfer between one-of-two accounts (checking and savings) . Basic format/outline: Please enter your ID: Please enter your PIN: What would you like to do: 1) Balance Inquiry 2) Deposit 3) Withdrawal 4) Transfer 5) Exit Upon leaving existing, please have the program print the current balance for the checking and savings account. The program should be written in simple code as its for a low level programming class. See attached documents for additional guidance. If possible, I'd like to have the program completed by the end of the day Tuesday, December 8th. I look forward to understanding next steps. Thank you for your time and consideration. Dale.
Answered Same Day Dec 01, 2021

Solution

Aditya answered on Dec 07 2021
155 Votes
import tkinte
from tkinter import *
from tkinter import messagebox
import time
import random
accountInformation = []
# defines the class BankAccount
def name_class_time():
print("\nIan Fordyce")
print("CIS 110 Program 10")
print(time.asctime(time.localtime(time.time())))
print()
name_class_time()
class BankAccount:
# defining account instance variables.
def __init__(self,userID, pin, savingBalance, checkingBalance ):
self.userID = userID
self.pin = pin
self.savingBalance = savingBalance
self.checkingBalance = checkingBalance
def getUserID(self):
return self.userID
def getPin(self):
return self.pin
def getSavingBalance(self):
return self.savingBalance
def getCheckingBalance(self):
return self.checkingBalance
# class function to calculate difference between the balance and the amount withdrawn.
def withdrawSavingBalance(self, amount):
self.savingBalance -= amount
def withdrawCheckingBalance(self, amount):
self.checkingBalance -= amount
def setSavingBalance(self, amount):
self.savingBalance = amount
def setCheckingBalance(self, amount):
self.checkingBalance = amount
# class function to calculate the sum between the balance and the amount deposited.
def depositSaving(self, amount):
self.savingBalance += amount
def depositChecking(self, amount):
self.checkingBalance += amount
def writeFile(self):
return str(self.userID)+','+str(self.pin)+','+str(self.savingBalance)+','+str(self.checkingBalance)
# class function to return the account balance
# class function to determine the balance transfe
def transfer(self, amount, ID):
self.total = self.balance - amount
ID.balance = ID.balance + amount
return ID.balance()
def updateAccount(bankAccount):
for i in accountInformation:
if i.getUserID() == bankAccount.userID:
i.setSavingBalance(bankAccount.getSavingBalance())
i.setCheckingBalance(bankAccount.getCheckingBalance())

eak
def readDataFromFile():
rd = open("bankAcoountData.txt", "r")
bankData = []
while True:
line = rd.readline()
if not line:

eak;
data = line.split(",")
userID = int(data[0])
pin = int(data[1])
savingBalance = float(data[2])
checkingBalance = float(data[3])
account = BankAccount(userID, pin, savingBalance, checkingBalance)
bankData.append(account)
rd.close()
return bankData
def writeToFile():
file = open('bankAcoountData.txt', 'w')
for i in accountInformation:
file.write(i.writeFile())
file.write('\n')
file.close()
accountInformation = readDataFromFile()
def login():
root = tkinter.Tk()
root.title("ATM")
root.wm_minsize(250, 200)
def close():
writeToFile()
root.destroy()
def checkAccount():
try:
userID = int(userIDtextBox.get())
pin = int(pinTextBox.get())
found = 0
for i in accountInformation:
if i.getUserID() == userID and i.getPin() == pin:
root.destroy()
mainScreen(i)
found = found + 1

eak
if found == 0:
tkinter.messagebox.showe
or('ATM', 'Inco
ect Credentials')
userIDtextBox.delete(0, "end")
userIDtextBox.insert(0, "")
pinTextBox.delete(0, "end")
pinTextBox.insert(0, "")
except ValueE
or:
tkinter.messagebox.showe
or('ATM', 'Inco
ect Format Enter Digits Only')
userIDtextBox.delete(0, "end")
userIDtextBox.insert(0, "")
pinTextBox.delete(0, "end")
pinTextBox.insert(0, "")
userIDlabel = tkinter.Label(text="Enter User ID: ", width=25)
userIDlabel.grid(column=0, row=0, padx=10, pady=10)
userIDtextBox = tkinter.Entry(width=25, relief="raised")
userIDtextBox.grid(column=1, row=0, padx=10, pady=10)
pinLabel = tkinter.Label(text="Enter PIN: ", width=25)
pinLabel.grid(column=0, row=1, padx=10, pady=10)
pinTextBox = tkinter.Entry(width=25, relief="raised")
pinTextBox.grid(column=1, row=1, padx=10, pady=10)
exitbutton = tkinter.Button(text="Exit", command=close, width=15, relief="raised")
exitbutton.grid(column=0, row=6, padx=10, pady=10)
checkbutton = tkinter.Button(text="Enter", command=checkAccount, width=15, relief="raised")
checkbutton.grid(column=1, row=6, padx=10, pady=10, sticky=W)
root.mainloop()
def mainScreen(bankAccount):
root = tkinter.Tk()
root.title("ATM")
root.wm_minsize(400, 150)
def...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here