215k views
1 vote
Write a program that calculates the amount of money in a savings account that earns a guaranteed yearly interest rate. The program will accept from the user the account is present value (i.e. what is in the savings account now), the annual interest rate (in a percentage), and the number of years the money will be left in the account (years). The program should display the savings account future value and the number of years the money will be left in the account.

1 Answer

5 votes

Solution :

# Reading principle amount from user


$\text{accountPresentValue}$ = eval(
$\text{inpu}t(Enter principle amount: "))

# Reading time duration in number of year from user

years = eval(input("Enter time duration in number of year: "))

# Reading interest rate from user

annualInterestRate = eval(input("Interest rate: "))

# calculating futureValue using user input data

futureValue = accountPresentValue * (1 + annualInterestRate / 100) ** years

# printing calculated futureValue to console

print("Final balance =",futureValue)

User Jackr
by
4.4k points