-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathaccount_test.py
35 lines (26 loc) · 1.15 KB
/
account_test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# this program demonstrates the BankAccount class.
# if import bankaccount shows a "Unresolved import"
# right click on project>Properties. Then click PyDev - PYTHONPATH
# click "External Libraries" . Then click add.
# choose the folder that the module is stored. Add apply
# restart the Eclipse
import bankaccount
def main():
# get the starting balance.
start_bal=float(input("Please enter your starting balance: "))
# create a BankAccount object.
savings=bankaccount.BankAccount(start_bal)
# deposit the user's paycheck.
pay=float(input("How much were you paid this week?: "))
print("I will deposit that into your account.")
savings.deposit(pay)
# display the balance.
print("Your account balance is $", format(savings.get_balance(), ",.2f"), sep="")
# get the amount to withdraw.
cash=float(input("How much would you like to withdraw?: "))
print("I will withdraw that from your account.")
savings.withdraw(cash)
# display the balance.
print("Your account balance is $", format(savings.get_balance(), ",.2f"), sep="")
# call the main function
main()