18.6k views
5 votes
Suppose you have a certain amount of money in a savings account that earns compound monthly interest, and you want to calculate the amount that you will have after a specific number of months. The formula is as follows:

f = p * (1 + i)^t
• f is the future value of the account after the specified time period.
• p is the present value of the account.
• i is the monthly interest rate.
• t is the number of months.
Write a program that takes the account's present value, monthly interest rate, and the number of months that the money will be left in the account as three inputs from the user. The program should pass these values to a function thatreturns the future value of the account, after the specified number of months. The program should print the account's future value.
Sample Run
Enter current bank balance:35.7↵
Enter interest rate:0↵
Enter the amount of time that passes:100↵ 35.7

2 Answers

7 votes

Answer:

here is the correct answer

Step-by-step explanation:

# The savings function returns the future value of an account.

def savings(present, interest, time):

return present * (1 + interest)**time

# The main function.

def main():

present = float(input('Enter current bank balance:'))

interest = float(input('Enter interest rate:'))

time = float(input('Enter the amount of time that passes:'))

print(savings(present, interest, time))

# Call the main function.

if __name__ == '__main__':

main()

User Jude Osborn
by
7.3k points
5 votes

Answer:

Here is an solution in Python.

Step-by-step explanation:

def calculate_future_value(p, i, t):

f = p * (1 + i)**t

return f

# Take user input

p = float(input("Enter current bank balance: "))

i = float(input("Enter interest rate: "))

t = int(input("Enter the amount of time that passes: "))

# Calculate future value

future_value = calculate_future_value(p, i/12, t)

# Print the future value

print("The account's future value is:", future_value)

User Child
by
7.6k points