Design a SavingAccount class data attributes: account_num, interest_rate, and balance
attributes: account_num, interest_rate, and balance
methods: get_account_num, check_balance, apply_interest, deposit, and withdraw
Design a CDAccount as a subclass of the SavingAccount class
new attributes: mini_balance
new methods: withdraw (this method should ensure the mini_balance in the account, otherwise displays "insufficient balance")
In the main() function, create an object of SavingAccount and perform deposit, apply interest, and withdraw operations; then create an object of CDAccount and perform the same series of operations.
A sample output of this program is given as follows.
Enter information for a saving account:
Account Number: 123
Interest Rate: 0.01
Initial Balance: 1200
Deposit Amount: 600
Account 123 Balance: $ 1800.0
Applying Interest
Account 123 Balance: $ 1818.0
Withdraw Amount: 800
Account 123 Balance: $ 1018.0
Enter information for a CD account:
Account Number: 321
Interest Rate: 0.03
Initial Balance: 2500
Minimum Balance: 2000
Deposit Amount: 800
Account321 Balance: $ 3300.0
Applying Interest
Account 321 Balance: $ 3399.0
Withdraw Amount: 1900
insufficient balance
Account 321 Balance: $ 3399.0
Coding is in python, below the image is what I've done so far. I can't figure out how to code insufficient balance part. So just please add coding for insufficient balance on what I've done. Please don't change my work. Just add that part. Thanks. Again, it is in python.

Respuesta :

Using the knowledge in computational language in python it is possible to write a code that just please add coding for insufficient balance on what I've done.

Writting the code:

class SavingAccount(object):

def __init__(self, account_num,interest_rate,balance):

self.account_num = account_num

self.interest_rate=interest_rate

self.balance=balance

def get_account_num(self):

return self.account_num

def check_balance(self):

return self.balance

def apply_interest(self,interest):

print("Applying Interest")

self.balance = int(self.balance)+(float(interest)*int(self.balance))

def deposit(self,depositamount):

self.balance=int(self.balance)+float(depositamount);

def withdraw(self):

withdrawamount=input("Withdraw Amount: ")

if float(withdrawamount)<float(self.balance):

self.balance=float(self.balance)-float(withdrawamount)

else:

print("insufficient balance")

class CDAccount(SavingAccount):

def __init__(self,account_num,interest_rate,balance,mini_balance):

SavingAccount.__init__(self,account_num,interest_rate,balance)

self.mini_balance=mini_balance

def withdraw(self):

withdrawamount=input("Withdraw Amount: ")

if float(self.balance)-float(withdrawamount)<0:

print("insufficient balance")

return None

self.balance=float(self.balance)-float(withdrawamount)

print("Enter information for a saving account:")

accountnumber=input("Account Number: ")

interest=input("Interest Rate: ")

balance=input("Initial Balance: ")

depositamount=input("Deposit Amount: ")

account = SavingAccount(accountnumber,interest,balance)

print("Enter information for a CD account:")

accountnumber=input("Account Number: ")

interest=input("Interest Rate: ")

balance=input("Initial Balance: ")

mini_balance=input("Minimum Balance: ")

depositamount=input("Deposit Amount: ")

See more about python at brainly.com/question/18502436

#SPJ1

Ver imagen lhmarianateixeira