Using object-oriented programming concepts, your task is to create a Python program that simulates a bank account.
- Your submitted code should be in a new (public) repo on Github.
- Your respository should have a minimum of 5 commits.
- Your repository should include a README with the name of your project and a description.
- Submit the link to your repo on Gradescope.
Your job is to create a Class that defines a bank account. It should define the owners name, account number, and balance as attributes.
Your BankAccount class should also define methods that perform common banking activities like deposit, withdraw, and get statement.
Follow the steps below:
- Your Python program should be created in one file called
bank_account.py
. - Define a
BankAccount
class. - A bank account should have the following attributes:
full_name
- the full name of the bank account account owner.account_number
- randomly generated 8 digit number, unique per account.balance
- the balance of money in the account, should start at 0.
- Then define the following methods for the
BankAccount
class:- The
deposit
method will take one parameteramount
and will addamount
to thebalance
. Also, it will print the message:“Amount deposited: $X.XX new balance: $Y.YY”
- The
withdraw
method will take one parameteramount
and will subtractamount
from thebalance
. Also, it will print a message, like“Amount withdrawn: $X.XX new balance: $Y.YY”
. If the user tries to withdraw an amount that is greater than the current balance, print”Insufficient funds.”
and charge them with an overdraft fee of$10
- The
get_balance
method willprint
a user-friendly message with the account balance and then alsoreturn
the currentbalance
of the account. - The
add_interest
method adds interest to the usersbalance
. The annual interest rate is 1% (i.e. 0.083% per month). Thus, the monthly interest is calculated by the following equation:interest = balance * 0.00083
. - The
print_statement
method prints a message with the account name, account number, and balance like this:
Joi Anderson Account No.: ****5678 Balance: $100.00
- The
- Outside of the BankAccount class, define 3 different bank account examples using the
BankAccount()
object.- Your examples should show you using the different methods above to demonstrate them working.
- Include example code to do the following:
- Create a new bank account instance: user: "Mitchell", account number: 03141592.
- Deposit $400,000 into "Mitchell's" account.
- Print a statement
- Add interest to the account
- Print a statement
- Make a withdrawl of $150 (Mitchell needs some Yeezy's)
- Print a statement
- Add an attribute to set the account type: checking or savings.
- A savings account gets 1.2% insterest (that's 1% per month)
- Create a checking and a savings account
- Add interest to each account
- Print a statement for each account
- Create a list called: bank. Add all of your accounts to bank. Write a function that loops over all accounts in the list and calls the
add_interst
method of each. - Create an "application". Use a loop to prompt us for an action. Actions can be:
- Create account
- Prompt for name, number, and balance.
- Statement - prompts for the account number and prints the statement for that account.
- Deposit - prompts for account number and amount. Then makes a deposit.
- Withdraw - prompts for account number and amount. Then makes a withdrawl
- Create account
- Create a Bank class. This class will store a list of BackAccounts. It should implement the following methods:
- create_account() - creates a new account.
- deposit() - deposits an amount into an account with an account number
- withdraw() - removes an amount from an account with an account number
- transfer() - withdraws an amount from an account with an account number and deposits the same amount to an account with another number.
- statement() - prints an statement for an account with an account number.
Use this rubric to measure your the success with this project: Bank Account Rubric