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

ITECH1400_Assignment_2/123456.txt 123456 7890 5000.0 0.33 Deposit 3000.0 Deposit 4000.0 Withdrawal 2000.0 ITECH1400_Assignment_2/bankaccount.py class BankAccount(): def __init__(self): '''Constructor...

1 answer below »
ITECH1400_Assignment_2/123456.txt
123456
7890
5000.0
0.33
Deposit
3000.0
Deposit
4000.0
Withdrawal
2000.0
ITECH1400_Assignment_2
ankaccount.py
class BankAccount():
def __init__(self):
'''Constructor to set account_number to '0', pin_number to an empty string,
XXXXXXXXXXbalance to 0.0, interest_rate to 0.0 and transaction_list to an empty list.'''

def deposit_funds(self, amount):
'''Function to deposit an amount to the account balance. Raises an
XXXXXXXXXXexception if it receives a value that cannot be cast to float.'''

def withdraw_funds(self, amount):
'''Function to withdraw an amount from the account balance. Raises an
XXXXXXXXXXexception if it receives a value that cannot be cast to float. Raises
XXXXXXXXXXan exception if the amount to withdraw is greater than the available
XXXXXXXXXXfunds in the account.'''
def get_transaction_string(self):
'''Function to create and return a string of the transaction list. Each transaction
XXXXXXXXXXconsists of two lines - either the word "Deposit" or "Withdrawal" on
XXXXXXXXXXthe first line, and then the amount deposited or withdrawn on the next line.'''
def save_to_file(self):
'''Function to overwrite the account text file with the cu
ent account
XXXXXXXXXXdetails. Account number, pin number, balance and interest (in that
XXXXXXXXXXprecise order) are the first four lines - there are then two lines
XXXXXXXXXXper transaction as outlined in the above 'get_transaction_string'
XXXXXXXXXXfunction.'''
ITECH1400_Assignment_2/ITECH1400_Assignment_2_FedUni_Banking.pdf
ITECH1400 – Foundations of Programming
School of Science, Engineering and Information Technology
CRICOS Provider No. 00103D Page 1 of 10
ITECH1400 - Assignment 2 – FedUni Banking
Due Date: 5pm, Friday of Week 11
This assignment will test your skills in designing and programming applications to specification and is worth
20% of your non-invigilated (type A) marks for this course. This is an INDIVIDUAL ASSIGNMENT – and while
you may discuss it with your fellow students, you must not share designs or code or you will be in
each of
the university plagiarism rules. This assignment should take you approximately 20 hours to complete.
Assignment Overview
You are tasked with creating an application that uses a GUI that simulates a simple banking interface similar to
an ATM / online banking using the Python 3 programming language.
The assignment is
oken up into five main components:
1.) The ability to provide an account number and a PIN
(Personal Identification Number) to sign into a bank
account,

2.) The ability to view the balance of the bank account and
to deposit and withdraw virtual money into and out
from the account,

3.) The ability to save transactions via file storage so that
you can log in, deposit some money and then log out –
and when you log back in that money is still there, and
finally

4.) The ability to display a graph of projected earnings on
the bank account via the compound interest accrued
over a variable amount of time.

5.) A Test Case that ensures your BankAccount's deposit and withdraw functionality operates co
ectly.
Your submission should consist of three Python scripts that implement this application as described in the
following pages: bankaccount.py, main.py along with a testbankaccount.py which contains a small test case
with a few simple unit tests than ensure that your bank accounts deposit_funds and withdraw_funds methods
operate co
ectly.
You are provided with a 'stub' of each of these files which contain all the function declarations and comments
which describe the role of the function and how it can be put together, but you will have to write the code for
vast majority of the functions yourself. You are also provided with a stub of the bankaccounttestcase.py file.
Your final submission should be a zipped archive (i.e. ‘zip file’) containing your completed Python scripts.
There is no word processed component to this second assignment.
ITECH1400 – Foundations of Programming
School of Science, Engineering and Information Technology
CRICOS Provider No. 00103D Page 2 of 10
Bank Account Class Design
The design for a BankAccount object is laid out in the following class diagram:



As you might imagine, the deposit_funds(amount) function adds that money to the cu
ent balance of the
account, and the withdraw_funds(amount) function removes (i.e. subtracts) money from the cu
ent balance
of the account. Each transaction in the transaction_list is a tuple containing either the word Deposit or the word
Withdrawal followed by an amount, for example: ("Deposit", XXXXXXXXXXor ("Withdrawal", 100.0).
The bank accounts in our program do not have an overdraft facility so the user cannot withdraw money they
do not have – that is, if they had $200 in their account and they tried to withdraw more than $200 then the
operation should fail and the withdraw_funds function should raise an Exception with a suitable e
or message
which is caught and displayed in the main.py file where the operation was attempted.
All e
or messages such as those from exceptions should be displayed in a pop-up messagebox.
The get_transaction_string method should loop over all the transactions in the transaction_list creating a string
version (with newline characters) of all the transactions associated with the account.
The save_to_file function should save the account_number, pin_number, balance, and interest_rate in that
order to a file called .txt followed by the transaction list string generated from the
get_transaction_string() method. The name of the account file is NOT '.txt' - the name of
the file is the ACTUAL ACCOUNT NUMBER followed by ".txt", so for an account with account_number 123456
the name of the account file would be XXXXXXXXXXtxt.
A full ‘walk-through’ video demonstrating the completed application and how it operates will be provided along
with this assignment document.
BankAccount
account_number: int
pin_number: string
alance: float
interest_rate: float
transaction_list: list of two-tuples
deposit_funds(amount)
withdraw_funds(amount)
get_transaction_string()
save_to_file()
ITECH1400 – Foundations of Programming
School of Science, Engineering and Information Technology
CRICOS Provider No. 00103D Page 3 of 10
Calculating Interest
To make it worthwhile for you to keep your money with a bank, the bank offers you an interest rate on your
savings. Interest will be applied to the balance of an account once per month.
Let’s do an example – suppose you had $10,000 in a bank account and the bank paid you monthly interest at a
ate of 3% per year. That would mean the bank pays you 3% of your balance divided by 12 (because there are
12 months in a year) per month. If we start our example on January and run it for a few months (and we don’t
deposit or withdraw any money throughout the year) then we end up with our bank balance changing like this:

Note: 3% divided by 12 is 0.25% per month – so we’ll multiply our balance by XXXXXXXXXXto get the new balance.
Jan Feb Mar Apr May Jun Jul Aug Etc.
10, XXXXXXXXXX, XXXXXXXXXX, XXXXXXXXXX, XXXXXXXXXX, XXXXXXXXXX, XXXXXXXXXX, XXXXXXXXXX,176.32 …

What’s happening here is that the interest is compounding – which just means that we get that 0.25% applied
not only to our principle balance (i.e. the $10,000 we started with), but it also gets applied to the interest we
earnt. Although 3% interest is very low (but in line with the best rates you’d get in Australia at the moment
ecause interest rates are very low), over time this compounding makes a serious difference!
Because FedUni Bank is the greatest bank of all time, it offers all accounts an interest rate of 33%.
The Main Python Script
Our main.py script will contain all the main logic for our program. It will allow us to:
- Enter an account number via an Entry field by using the keyboard,
- Enter a PIN number via an Entry widget (we can use the keyboard OR a series of buttons to enter the
PIN),
- Once we are logged in we must be able to:
o See the balance of our account,
o Deposit funds into our account,
o Withdraw funds from our account (only up to the amount we have available),
o Display a plot of our projected interest over the next 12 months as outlined above, and finally
o Log out of our account.
Every time a successful deposit or withdrawal is made then a new transaction should be added to the account's
transaction list. When we log out then the account file is overwritten with the new account details including
our new balance and any transactions if any have been made.
The format of the account text file is as follows (each value on separate lines):
account_number
account_pin
alance
interest_rate
ITECH1400 – Foundations of Programming
School of Science, Engineering and Information Technology
CRICOS Provider No. 00103D Page 4 of 10
For example, account number XXXXXXXXXXwith PIN 7890 and a balance of $800 with an interest rate of 33% would
look like this:
123456
7890
800.00
0.33

After these first four lines we may have a number of transactions, each of which is specified as two lines. A
deposit is indicated by the word Deposit on one line and then the amount on the next like. For example a
deposit of $500 would look like this:
Deposit
500.00

Similarly, a withdrawal is also specified as two lines – first the word Withdrawal and then on the next line the
amount, for example a withdrawal of $200 would look like this:
Withdrawal
200.00
Answered Same Day May 22, 2020 ITECH1400

Solution

Abr Writing answered on May 31 2020
139 Votes
123456.txt
123456
7890
27000.0
0.33
Deposit
3000.0
Deposit
4000.0
Withdrawal
2000.0
Deposit
4000.0
Deposit
20000.0
testbankaccount.py
import unittest
from bankaccount import BankAccount
class TestBankAcount(unittest.TestCase):
def setUp(self):
# Create a test BankAccount object
self.account = BankAccount()
# Provide it with some property values
self.account.balance = 1000.0
def test_legal_deposit_works(self):
# Your code here to test that depsositing money using the account's
# 'deposit_funds' function adds the amount to the balance.
self.account.deposit_funds(100.0)

def test_illegal_deposit_raises_exception(self):
# Your code here to test that depositing an illegal value (like 'bananas'
# or such - something which is NOT a float) results in an exception being
# raised.
self.account.deposit_funds('bananas')
def test_legal_withdrawal(self):
# Your code here to test that withdrawing a legal amount subtracts the
# funds from the balance.
self.account.withdraw_funds(100.0)

def test_illegal_withdrawal(self):
# Your code here to test that withdrawing an illegal amount (like 'bananas'
# or such - something which is NOT a float) raises a suitable exception.
self.account.withdraw_funds('bananas')
def test_insufficient_funds_withdrawal(self):
# Your code here to test that you can only withdraw funds which are available.
# For example, if you have a balance of 500.00 dollars then that is the maximum
# that can be withdrawn. If you tried to withdraw 600.00 then a suitable exception
# should be raised and the withdrawal should NOT be applied to the account balance
# or the account's transaction list.
self.account.withdraw_funds(5000.0)
# Run the unit tests in the above test case
unittest.main()
ankaccount.py
class BankAccount():
def __init__(self):
'''Constructor to set account_number to '0', pin_number to an empty string,
balance to 0.0, interest_rate to 0.0 and transaction_list to an empty list.'''
self.account_number = '0'
self.pin_number = ''
self.balance = 0.0
self.interest_rate = 0.0
self.transaction_list = list()

def deposit_funds(self, amount):
'''Function to deposit an amount to the account balance. Raises an
exception if it receives a value that cannot be cast to float.'''
try:
    self.balance += float(amount)
    self.transaction_list.append(("Deposit", amount))
except:
    raise Exception('Value received is not valid')

def withdraw_funds(self, amount):
'''Function to withdraw an amount from the account balance. Raises an
exception if it receives a value that cannot be cast to float. Raises
an exception if the amount to withdraw is greater than the available
funds in the account.'''
try:
    if float(amount) <= self.balance:
        self.balance = self.balance - float(amount)
        self.transaction_list.append(("Withdrawal", amount))
    else:
        raise Exception('Amount to withdraw is greater than the available funds in the account')
except:
    raise Exception('Value received is not valid')     
def get_transaction_string(self):
'''Function to create and return a string of the transaction list. Each transaction
consists of two lines - either the word "Deposit" or "Withdrawal" on
the first line, and then the amount deposited or withdrawn on the next line.'''
return self.transaction_list
def save_to_file(self):
'''Function to overwrite the account text file with the cu
ent account
details. Account number, pin number, balance and interest (in that
precise order) are the first four lines - there are then two lines
per transaction as outlined in the above 'get_transaction_string'
function.'''
f = open(self.account_number+'.txt', 'w')
f.write(self.account_number+'\n')
f.write(self.pin_number+'\n')
f.write(str(self.balance)+'\n')
f.write(str(self.interest_rate)+'\n')
for transaction in self.transaction_list:
    f.write(transaction[0]+'\n')
    f.write(transaction[1]+'\n')
f.close()
main.py
import tkinter as tk
from tkinter import messagebox
from pylab import plot, show, xlabel, ylabel
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg
from matplotlib.figure import Figure
from bankaccount import BankAccount
win = tk.Tk()
# Set window size here to '440x640' pixels
win.geometry('440x640')
# Set window title here to 'FedUni Banking'
win.title('FedUni Banking')
# The account number entry and associated variable
account_number_var = tk.StringVar()
account_number_entry = tk.Entry(win, textvariable=account_number_var)
account_number_entry.focus_set()
# The pin number entry and associated variable.
# Note: Modify this to 'show' PIN numbers as asterisks (i.e. **** not 1234)
pin_number_var = tk.StringVar()
account_pin_entry = tk.Entry(win, text='PIN Number', textvariable=pin_number_var, show='*')
# The balance label and associated variable
alance_var = tk.StringVar()
alance_var.set('Balance: $0.00')
alance_label = tk.Label(win, textvariable=balance_var)
# The Entry widget to accept a numerical value to deposit or withdraw
amount_entry = tk.Entry(win)
# The transaction text widget holds text of the accounts transactions
transaction_text_widget = tk.Text(win, height=10, width=48)
# The bank account object we will work with
account = BankAccount()
# ---------- Button Handlers for Login Screen ----------
def clear_pin_entry(event):
'''Function to clear the PIN number entry when the Clear / Cancel button is clicked.'''
# Clear the pin number entry here
pin_number_var.set('')
def handle_pin_button(event):
'''Function to add the number of the button clicked to the PIN number entry via its associated variable.'''
# Limit to 4 chars in length
pin = account_pin_entry.get()
# Set the new pin number on the pin_number_va
if len(pin)...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here