Skip to content
Open
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
822bf98
lab12 ATM w/ Version 2
JohnnyMurph22 Mar 2, 2022
d3e445d
Lab 12 corrections made, per @IrronWilliams comments, added print tra…
JohnnyMurph22 Mar 5, 2022
42063c9
committing lab 1 HTML/CSS
JohnnyMurph22 Mar 5, 2022
69e40a0
Lab2 HTML in-progress
JohnnyMurph22 Mar 10, 2022
e8be06f
Lab 14 Dad Joke API
JohnnyMurph22 Mar 11, 2022
74b6e37
Lab 3 in-progress
JohnnyMurph22 Mar 15, 2022
e2e62c0
Lab 3 html and css files
JohnnyMurph22 Mar 16, 2022
c649fbe
Lab 5 In-Progress
JohnnyMurph22 Mar 16, 2022
af76f41
Lab 5 Forms: Complete
JohnnyMurph22 Mar 18, 2022
abcd79b
Lab 6: Flask ROT13 CIPHER -- In-Progress
JohnnyMurph22 Mar 19, 2022
bcd57eb
Lab6 Flask ROT13
JohnnyMurph22 Mar 22, 2022
5405ffc
Django tutorials + Lab 1-in-progress
JohnnyMurph22 Mar 25, 2022
de18282
Django_Redo_Lab1 -- still in-progress; Day 4 -- still troubleshooting…
JohnnyMurph22 Mar 31, 2022
155664a
Lab1 Django - complete/ template inheritance demo
JohnnyMurph22 Apr 1, 2022
b9b6d5b
Django_Lab2 Grocery List in-progress
JohnnyMurph22 Apr 1, 2022
9ebd5ee
todo project demo
JohnnyMurph22 Apr 5, 2022
de723cb
Lab 2 todo_proj; in-progress
JohnnyMurph22 Apr 8, 2022
a0eac4e
Grocery_app - working
JohnnyMurph22 Apr 12, 2022
0a726c4
I've been referencing 'https://ireadblog.com/accounts/profile/ashutos…
JohnnyMurph22 Apr 12, 2022
f42d4e8
Grocery Lab -- Mob
JohnnyMurph22 Apr 13, 2022
b59b331
Mob lab phone book
JohnnyMurph22 Apr 14, 2022
0d71689
Todo Lab updates
JohnnyMurph22 Apr 15, 2022
0ea4d80
Java Lab 1 - inprogress/day 1
JohnnyMurph22 Apr 21, 2022
e6bde9c
Lab 1 Java inprogress day2; still debugging incrementscore function/ …
JohnnyMurph22 Apr 22, 2022
05fe514
Todo Labs
JohnnyMurph22 Apr 26, 2022
7a08df4
Jave Lab2 complete-- class nts 4/26
JohnnyMurph22 Apr 27, 2022
9722ea2
Django Blog Lab Redo
JohnnyMurph22 Apr 28, 2022
912669a
Java Lab 1 redo 'RPS'
JohnnyMurph22 Apr 29, 2022
f9e1bf9
RPS redo finished - type2
JohnnyMurph22 Apr 30, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 81 additions & 0 deletions Code/johnathan/python/lab12.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@

# # Lab 12: ATM w/ Version 2

# Let's represent an ATM with a class containing two attributes:
# a balance and an interest rate. A newly created account will default to a balance of 0
# and an interest rate of 0.1%. Implement the initializer, as well as the following functions:


class ATM:
def __init__(self):
self.balance = 0
self.interest_rate = 0.1
self.transactions = [] #Add a new method `print_transactions()` to your class for printing out the list of transactions,

# - `check_balance()` returns the account balance
def check_balance(self):
account_balance = self.balance
return account_balance
# - `deposit(amount)` deposits the given amount in the account
def deposit(self, amount):
self.transactions.append(f'User deposited ${amount}')
self.balance = self.balance + amount
return amount
# - `check_withdrawal(amount)` returns true if the withdrawn amount won't
# put the account in the negative
def check_withdrawal(self, amount):
if amount < self.balance >= 0:
return True
else:
return False
#withdraws the amount from the account and returns it
def withdraw(self, amount):
self.transactions.append(f'User withdrew ${amount}')
amount = self.balance - amount
return amount
#returns the amount of interest calculated on the account
def calc_interest(self):
amount = self.interest_rate * self.balance
return amount
#print user transactions
def user_transaction(self):
return self.transactions

atm = ATM() # create an instance of our class
print('Welcome to the ATM')
while True:
command = input('Enter a command: ')
if command == 'balance':
balance = atm.check_balance() # call the check_balance() method
print(f'Your balance is ${balance}')
elif command == 'deposit':
amount = float(input('How much would you like to deposit? '))
atm.deposit(amount) # call the deposit(amount) method
print(f'Deposited ${amount}')
elif command == 'withdraw':
amount = float(input('How much would you like '))
if atm.check_withdrawal(amount): # call the check_withdrawal(amount) method
atm.withdraw(amount) # call the withdraw(amount) method
print(f'Withdrew ${amount}')
else:
print('Insufficient funds')
elif command == 'interest':
amount = atm.calc_interest() # call the calc_interest() method
atm.deposit(amount)
print(f'Accumulated ${amount} in interest')
elif command == 'help':
print('Available commands:')
print('balance - get the current balance')
print('deposit - deposit money')
print('withdraw - withdraw money')
print('interest - accumulate interest')
print('exit - exit the program')
elif command == 'exit':
break
else:
print('Command not recognized')