I need to write a code that displays the a return of investments for 0 to 20 years or when the today's value has reached .5 * of the investment initial invested amount. i am stuck with the latter part. when i use an IF statment, i couldn't get any value. here is my code.
def getExpInvestAmt(investAmt, i, n):
expInvestAmt = int(investAmt * pow(1 + i / 100, n))
return expInvestAmt
def getPresentValue(exp_invest_amt, d, n):
adjAmt = int(exp_invest_amt / pow(1 + d / 100, n))
return adjAmt
def main():
investAmt = float(input("Enter investment amount:"))
i = float(input("Enter the expected investment growth rate:"))
d = float(input("Enter the discount rate:"))
n = 0
adjA = 0
print("Year \t Value at year($) \t Today's worth($)")
for x in range(0, 21):
if adjA < 0.5 * investAmt
break
expected_value = getExpInvestAmt(investAmt, i, n)
present_value = getPresentValue(expected_value, d, n)
n += 1
adjA += 1
print("{} \t {:,} \t {:,}".format(x, expected_value, present_value))
main()
this is what i am suppose to get,
Aucun commentaire:
Enregistrer un commentaire