Question

In: Computer Science

IN PYTHON: write a new subclass hiAccount that allows you to earn interest at the rate...

IN PYTHON:

write a new subclass hiAccount that allows you to earn interest at the rate of .01% per SECOND.

Write a new method called checkBalance for hiAccount that computes hiAccount's value, accounting for the growth of your hiAccount between when the time when the deposit was made and when you invoke checkBalance.

using following code:

class Account:
"""A bank account that has a non-negative balance."""
def __init__(self, account_holder):
"""Every Account is described using the name of the account holder, which is a string."""
self.balance = 0
self.holder = account_holder
def deposit(self, amount):
"""Increase the account balance by amount and return the new balance."""
self.balance = self.balance + amount
return self.balance
def withdraw(self, amount):
"""Decrease the account balance by amount and return the new balance."""
if amount > self.balance:
return 'Insufficient funds'
self.balance = self.balance - amount
return self.balance

Solutions

Expert Solution

code:

Account.py

class Account:
   """A bank account that has a non-negative balance."""
   def __init__(self, account_holder):
       """Every Account is described using the name of the account holder, which is a string."""
       self.balance = 0
       self.holder = account_holder
   def deposit(self, amount):
       """Increase the account balance by amount and return the new balance."""
       self.balance = self.balance + amount
       return self.balance
   def withdraw(self, amount):
       """Decrease the account balance by amount and return the new balance."""
       if amount > self.balance:
           return 'Insufficient funds'
       self.balance = self.balance - amount
       return self.balance

hiAccount.py:

import time
import math
from Account import Account
class hiAccount(Account):
   def __init__(self, account_holder):
       Account.__init__(self,account_holder)
       self.currentime=time.time()
   def checkBalance(self):
       time_now=time.time()
       self.balance=(self.balance)*(1+0.01/100)**math.floor((time_now-self.currentime))
       self.currentime=time_now
       return self.balance

hiAccountHolder1=hiAccount('Adam')
hiAccountHolder1.deposit(100)

hiAccountHolder1.currentime=time.time()
print("Hi "+hiAccountHolder1.holder+" 100 bucks is deposited in your account:")
print("Updated balance is")
print(hiAccountHolder1.checkBalance())
time.sleep(10)
print("After 10 seconds, updated balance is:")
print(hiAccountHolder1.checkBalance())

Reference for indendation:

Sample i/o:

Explanation: To demonstrate the compouding for every second, I have used sleep(10). The check balance method, keeps track of the balance updated time and the present time and calculates a compound interest.
Sample i/o is presented for better understanding. The program is run in python 3.7.

**Please upvote if you like the answer


Related Solutions

The YTM on a bond is the interest rate you earn on your investment if interest...
The YTM on a bond is the interest rate you earn on your investment if interest rates don’t change. If you actually sell the bond before it matures, your realized return is known as the holding period yield (HPY). A.) Suppose that today you buy a bond with an annual coupon rate of 7 percent for $1,060. The bond has 21 years to maturity. What rate of return do you expect to earn on your investment? Assume a par value...
The YTM on a bond is the interest rate you earn on your investment if interest...
The YTM on a bond is the interest rate you earn on your investment if interest rates don’t change. If you actually sell the bond before it matures, your realized return is known as the holding period yield (HPY). a. Suppose that today you buy an annual coupon bond with a coupon rate of 8.4 percent for $775. The bond has 7 years to maturity and a par value of $1,000. What rate of return do you expect to earn...
The YTM on a bond is the interest rate you earn on your investment if interest...
The YTM on a bond is the interest rate you earn on your investment if interest rates don’t change. If you actually sell the bond before it matures, your realized return is known as the holding period yield (HPY). a. Suppose that today you buy a bond with an annual coupon rate of 8 percent for $1,170. The bond has 16 years to maturity. What rate of return do you expect to earn on your investment? Assume a par value...
The YTM on a bond is the interest rate you earn on your investment if interest...
The YTM on a bond is the interest rate you earn on your investment if interest rates don’t change. If you actually sell the bond before it matures, your realized return is known as the holding period yield (HPY). a. Suppose that today you buy an annual coupon bond with a coupon rate of 8.1 percent for $855. The bond has 7 years to maturity and a par value of $1,000. What rate of return do you expect to earn...
The YTM on a bond is the interest rate you earn on your investment if interest...
The YTM on a bond is the interest rate you earn on your investment if interest rates don’t change. If you actually sell the bond before it matures, your realized return is known as the holding period yield (HPY). a. Suppose that today you buy a bond with an annual coupon rate of 10 percent for $1,190. The bond has 18 years to maturity. What rate of return do you expect to earn on your investment? Assume a par value...
The YTM on a bond is the interest rate you earn on your investment if interest...
The YTM on a bond is the interest rate you earn on your investment if interest rates don’t change. If you actually sell the bond before it matures, your realized return is known as the holding period yield (HPY). a. Suppose that today you buy a bond with an annual coupon rate of 11 percent for $1,060. The bond has 20 years to maturity. What rate of return do you expect to earn on your investment? Assume a par value...
The YTM on a bond is the interest rate you earn on your investment if interest...
The YTM on a bond is the interest rate you earn on your investment if interest rates don’t change. If you actually sell the bond before it matures, your realized return is known as the holding period yield (HPY). a. Suppose that today you buy a bond with an annual coupon of 10 percent for $1,120. The bond has 17 years to maturity. What rate of return do you expect to earn on your investment? Assume a par value of...
The YTM on a bond is the interest rate you earn on your investment if interest...
The YTM on a bond is the interest rate you earn on your investment if interest rates don’t change. If you actually sell the bond before it matures, your realized return is known as the holding period yield (HPY). a. Suppose that today you buy a bond with an annual coupon of 11 percent for $1,060. The bond has 20 years to maturity. What rate of return do you expect to earn on your investment? Assume a par value of...
The YTM on a bond is the interest rate you earn on your investment if interest...
The YTM on a bond is the interest rate you earn on your investment if interest rates don’t change. If you actually sell the bond before it matures, your realized return is known as the holding period yield (HPY). a. Suppose that today you buy a bond with an annual coupon of 11 percent for $1,060. The bond has 20 years to maturity. What rate of return do you expect to earn on your investment? Assume a par value of...
The YTM on a bond is the interest rate you earn on your investment if interest...
The YTM on a bond is the interest rate you earn on your investment if interest rates don’t change. If you actually sell the bond before it matures, your realized return is known as the holding period yield (HPY). a. Suppose that today you buy a bond with an annual coupon rate of 8 percent for $1,100. The bond has 15 years to maturity. What rate of return do you expect to earn on your investment? Assume a par value...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT