How much money will I accumulate over x amount of years

2 次查看(过去 30 天)
Create a loop to find how much money I will have after n amount of years. You have an initial deposit of $1000 and add $65 each month to an account that gains 1.5% each month. How much money will you have after 13 years?
  2 个评论
madhan ravi
madhan ravi 2020-6-5
Are you asking or stating? What have you tried for your homework?
Dillan Guzman
Dillan Guzman 2020-6-5
Asking. I know how to solve the question but not as a loop.
d0=input('Initial deposit: ');
d=input('How much will you contribute each month: '); %how much I will add/month
rate=input('Enter interest rate: '); %interest rate/month
r=rate/100;
n=input('Enter how many years you plan on investing: ')
x=n*12; %number of months
monthly_gain=(d0+d*x)*r;
tot_d=d0+d*x;
tot_gain=monthly_gain+tot_d

请先登录,再进行评论。

回答(1 个)

James Tursa
James Tursa 2020-6-5
编辑:James Tursa 2020-6-5
Those last three lines need to be put into a loop. That is, each month this happens to the balance
balance = balance * (1 + r) + d
So, start the balance out at the initial value d0, and then the loop needs to iterate this line for x times.

类别

Help CenterFile Exchange 中查找有关 Function Creation 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by