while loops with compound interest
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
hello, i am trying to work out a problem that i am having with while loops. i have to determine how much to save each month in order to reach a goal of 100836 in 216 months. the interest rate is 5.5 per year. so far, i have written the following script but the number does not seem believable to me.
%minimum deposit in 18 years
n=18*12;
balance= 2000;
deposit=200;
while balance<100836.46
balance=balance*(1+(5.5/1200))+deposit;
deposit=deposit+50+(20*n);
end
disp(deposit)
disp(balance)
i end up getting an odd number which is 35160. i think that the number should be in the 200's assuming that the initial deposit is 200.
3 comentarios
Walter Roberson
el 2 de Nov. de 2015
When you ask the same question multiple times, the volunteers end up spending their time finding and merging the multiple questions, instead of spending their time answering questions.
Respuestas (1)
Walter Roberson
el 2 de Nov. de 2015
Why are you adding (20*n) each deposit period?
2 comentarios
Astha Sharma
el 2 de Nov. de 2015
Editada: Walter Roberson
el 3 de Nov. de 2015
Walter Roberson
el 3 de Nov. de 2015
initialize
while true
do a calculation
if we succeeded
break;
end
change the variables for the next try
end
Ver también
Categorías
Más información sobre Loops and Conditional Statements en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!