R Programming A bank offers a guaranteed investment certifi

R Programming - A bank offers a guaranteed investment certificate (GIC) which pays an annual interest rate of 4% (compounded annually) if the term is 3 years or less, or 5% if the term is more than 3 years. Write a function which takes the initial investment amount, P, and the number of interest periods (i.e. years) as arguments and which returns the amount of interest earned over the term of the GIC. That is, return I , where I = P((1 + i)^n 1).

Solution

def bank_solution(amount, years):
   if years < 3:
       I = amount*((1+0.04)**years-1)
   else:
       I = amount*((1+0.05)**years-1)

   return I

amount = input(\"Enter principle amount\")
years = input(\"Enter no of years\")
interest_earned = bank_solution(int(amount), int(years))
total_amount = int(amount) + interest_earned
print(total_amount)

R Programming - A bank offers a guaranteed investment certificate (GIC) which pays an annual interest rate of 4% (compounded annually) if the term is 3 years or

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site