-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathaccount demo.py
54 lines (45 loc) · 1.61 KB
/
account demo.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# This program creates an instance of the SavingsAccount
# class and an instance of the CD account.
import accounts
def main():
# Get the account number, interest rate,
# and account balance for a savings account.
print('Enter the following data for a savings account.')
acct_num = input('Account number: ')
int_rate = float(input('Interest rate: '))
balance = float(input('Balance: '))
# Create a SavingsAccount object.
savings = accounts.SavingsAccount()
# Get the account number, interest rate,
# account balance, and maturity date for a CD.
print('Enter the following data for a CD.')
acct_num = input('Account number: ')
int_rate = float(input('Interest rate: '))
balance = float(input('Balance: '))
maturity = input('Maturity date: ')
savings.set_account_num(acct_num)
savings.set_balance(balance)
savings.set_
# Create a CD object.
cd = accounts.CD()
# Display the data entered.
print('Here is the data you entered:')
print()
print('Savings Account')
print('---------------')
print('Account number:', savings.get_account_num())
print('Interest rate:', savings.get_interest_rate())
print('Balance: $', \
format(savings.get_balance(), ',.2f'), \
sep='')
print()
print('CD')
print('---------------')
print('Account number:', cd.get_account_num())
print('Interest rate:', cd.get_interest_rate())
print('Balance: $', \
format(cd.get_balance(), ',.2f'), \
sep='')
print('Maturity date:', cd.get_maturity_date())
# Call the main function.
main()