The (fictitious) company Let Me Retire has asked you to build a financial calcul
ID: 3641029 • Letter: T
Question
The (fictitious) company Let Me Retire has asked you to build a financial calculator that can be used to calculate the future value of a retirement account. In its simplest form, a retirement account is, essentially, an annual deposit in an interest-bearing account. Deposits are always made at the beginning of the year and the interest earned is based on the balance each year.For example, suppose you deposit $100.00 per year for two years in a 10% retirement account. In the first year you will earn $10.00 interest (i.e., 10% of $100.00) giving you a balance of $110.00 at the end of year 1. Then, at the beginning of year 2 you will deposit another $100.00, giving you a balance of $210.00. So, in the second year you will earn $21.00 interest (i.e., 10% of $210.00) giving you a balance of $231.00 at the end of year 2.
Required Program Structure and Function
Your application must consist of single function named main(). When executed, your application must:
1. Print a header.
2. Prompt the user to enter the size of the annual deposit.
3. Prompt the user to enter the interest rate.
4. Prompt the user to enter the number of years until retirement.
5. Calculate the future value of the retirement account (when the user retires).
6. Print the future value of the retirement account.
Explanation / Answer
def main():
print "Let Me Retire company's financial calculator"
print "This program calculates the future value of the retirement account "
deposit = input("Enter your annual deposit amount: ")
interest = input("Enter the interest rate(%): ")
years = input("Enter the number of years until retirement: ")
total = 0
while years > 0:
total, years = (total + deposit) * (1 + interest / 100.0), years - 1
print " The future value of the retirement account is $%.2f" %total
main()
Sample run
>>>
Let Me Retire company's financial calculator
This program calculates the future value of the retirement account
Enter your annual deposit amount: 100
Enter the interest rate(%): 10
Enter the number of years until retirement: 2
The future value of the retirement account is $231.00
>>>
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.