58.3k views
2 votes
(2) Suppose you deposit a certain amount of money into a savings account that earns compound monthly interest, and you want to calculate you will have after a specific amount number of months. The formula is:

F = P * (1 + i)t


Where the terms in the formula are as follows:

F is the future value of the account after the specified amount of time.

P is the present value, or the amount that you want deposit.

i is the monthly interest rate.

t is the number of months that you plan to let the money sit in the account.

Write a function called futureValue() that takes on three arguments: P, i and t which returns the future value.


javascript

1 Answer

5 votes

Answer:

Step-by-step explanation:

def compoundInterest (p, r, t):

f=p*pow((1+r/100), t)

return f

p=0

while p<=0:

p=float( input("\\Enter the present value of the account in dollars : "))

if p<=0:

print("\\Invalid value")

r=0

while r<=0 or r>100:

r=float( input("\\Enter the monthly interest rate as a percentage :"))

if r<=0 or r>100:

print("\\Invalid Value")

t=0

while t<=0:

t=float(input("\\Enter thr number of months :"))

if t<=0:

print("\\Invalid Value")

f=compoundInterest(p, r, t)

print("\\Present Value : $", p)

print("\\Interest Rate : % ", r)

print("\\After ",t , " months, the value of your account will be $ ", f)

User Iamtodor
by
5.4k points