フィルターのクリア

Using a loop to find out how long and how many terms

10 ビュー (過去 30 日間)
Steven
Steven 2012 年 4 月 1 日
コメント済み: Tyler Kelley 2018 年 4 月 6 日
So I have a problem that asks me to give a loop to see how long it takes to accumulate $1,000,000 in a bank account if you deposit $10,000 initially and $10,000 at the end of each year. Also the account pays 6% interest (0.06) each year.
Note:(The answer is 33 years, after 33 years the amount will be $1,041,800)
I've tried a while loop and can't arrive at that.
Please I need help!
Here is code I have so far:
money=10000; k=0; max=30;
while k > max
k=k+1;
money=money-(0.06*money);
if money > 1000000
break;
end
end
  3 件のコメント
Steven
Steven 2012 年 4 月 1 日
money=10000; k=0; max=30;
while k > max
k=k+1;
money=money-(0.06*money);
if money > 1000000
break;
end
end
I'm not getting any output for this. I don't know what to do.
Tyler Kelley
Tyler Kelley 2018 年 4 月 6 日
Balance = 10000; InterestRate = 1.06; Year = 0;
while Balance < 1000000
Balance = Balance*InterestRate + 10000;
Year = Year + 1;
end
disp(Year)

サインインしてコメントする。

採用された回答

bym
bym 2012 年 4 月 1 日
Check your math
clc;clear
dep = 10000;
account = 10000;
year = 0;
while account < 1000000
year = year+1;
account = account*1.06 + dep;
end
sprintf('after %d years, the total is %7.0f dollars',year,account)

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeIntroduction to Installation and Licensing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by