Suppose you have a certain amount of money in a savings account that earns compo
ID: 3552224 • Letter: S
Question
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 F = P X ( 1 + i ) ** t F = future value of the account P = present value of the account i = monthly interest rate t = the number of months. Write a program that prompts the user to enter the accounts present value, monthly interest rate, and number of months that the money will be left in the account. The program should pass these values to a function that returns the future value of the account after the specified number of months. The program should display the accounts future value.
Sample Run #1 GOOD Enter the present value of the account in dollars: 10000 Enter the monthly interest rate a s a percentage: 1.2 Enter the number of months: 36 The inform ation for your account is: Present value: $ 10000.00 Interest Rate: % 1.20 After 36 months, the value of your account will be $ 15363.79
Sample Run #2 BAD Enter the present value of the account in d ollars: 1000 Enter the monthly interest rate as a percentage: 110 Invalid value Enter the monthly interest rate as a percentage: 1.1 Enter the number of months: - 10 Invalid value Enter the number of months: 10 The information for your account is: Present value: $ 1000.00 Interest Rate: % 1.10 After 10 months, the value of your account will be $ 1115.61
THE OUT PUT NEEDS TO FOLLOW GUIDELINES ON SAMPLE RUN!
Explanation / Answer
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)
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.