Question

# q11 - DEBUG function futureValue(principal,N,interestRate) # - This function currently returns INCORRECT answers # -...

# q11 - DEBUG function futureValue(principal,N,interestRate)
# - This function currently returns INCORRECT answers
# - Find and fix the errors in the function below
#
# - the program accepts 3 parameters:
# --- principal - float (starting amount)
# --- N - integer (number of years)
# --- interestRate - float (value less than 1)
#
# - futureValue should calculate the future value of the principal
# when invested at the interestRate for N years. Interest is
# compounded at the end of each year.
#
# - Example:
# principal = 1000.00
# N = 3
# interestRate = .05 (this is 5%)
#
# The value at the end of each year is:
# N1: 1000.00 * 1.05 = 1050.00
# N2: 1050.00 * 1.05 = 1102.50
# N3: 1102.50 * 1.05 = 1157.625
#
# return 1157.625

0 0
Add a comment Improve this question Transcribed image text
Answer #1

In case of any query do comment. Please rate answer as well. Thanks

Code:

# q11 - DEBUG function futureValue(principal,N,interestRate)
# - This function currently returns INCORRECT answers
# - Find and fix the errors in the function below
#
# - the program accepts 3 parameters:
# --- principal - float (starting amount)
# --- N - integer (number of years)
# --- interestRate - float (value less than 1)
#
# - futureValue should calculate the future value of the principal
# when invested at the interestRate for N years. Interest is
# compounded at the end of each year.
#
# - Example:
# principal = 1000.00
# N = 3
# interestRate = .05 (this is 5%)
#
# The value at the end of each year is:
# N1: 1000.00 * 1.05 = 1050.00
# N2: 1050.00 * 1.05 = 1102.50
# N3: 1102.50 * 1.05 = 1157.625
#
# return 1157.625

def futureValue(principal,N,interestRate):
amount = principal
for i in range(N):
amount = amount + (amount * interestRate)
print("N{}: Amount: {}".format(i+1,amount))
return amount

#main driver function
amount = futureValue(1000,3,0.05)
print("Future Value: ", amount)

==========Screen shot of the code for indentation=======

WONO main.py 1 # 911 - DEBUG function futureValue(principal, n, interestRate) 2 # - This function currently returns INCORRECT

Output:

N1: Amount: 1050.0 N2: Amount: 1102.5 N3: Amount: 1157.625 Future Value: 1157.625 ... Program finished with exit code 0 Press

Add a comment
Know the answer?
Add Answer to:
# q11 - DEBUG function futureValue(principal,N,interestRate) # - This function currently returns INCORRECT answers # -...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • please follow the instruction ( very important ) 1912275-dt content-rid 43901523 1/courses/CSct A31. (25 pts) You...

    please follow the instruction ( very important ) 1912275-dt content-rid 43901523 1/courses/CSct A31. (25 pts) You must use a tor loop in the following program Write, compile, debug, and run a program that will use a for loop to do the following Some investments compound interest. This means that the interest is added onto the balance periodically during the year, and the next interest is calculated on this larger balance. This makes the actual return on investment actually greater than...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT