60.5k views
3 votes
python Write a function that computes a future investment value at a given interest rate for a specified number of years. The future investment is determined using the formula in Programming Exercise 2.19 in Chapter 2 Programming Exercise from the Book.

User Jekayode
by
5.8k points

1 Answer

1 vote

Answer:

def future_investment_value(investment, monthly_interest_rate, years):

print("Years\tFuture Value")

print("- - - - - - - - - - -")

for i in range(1, years+1):

future_value = investment * ((1 + monthly_interest_rate) ** (12 * i))

print(i, "\t\t", format(future_value, ".2f"))

investment = float(input("Enter the invesment amount: "))

interest = float(input("Enter the annual interest rate: "))

year = int(input("Enter the year: "))

future_investment_value(investment, interest/1200, year)

Step-by-step explanation:

Inside the function:

- In the for loop that iterates through the years, calculate the future value using the formula and print the results

Then:

- Ask the user for the investment, annual interest rate, and year

- Call the function with the given inputs

User Ismail Sahin
by
4.4k points