Easier ways to write this scipt.

2 ビュー (過去 30 日間)
Kristian Torres
Kristian Torres 2019 年 12 月 1 日
回答済み: Bhaskar R 2019 年 12 月 1 日
clear;
clc;
balance = 1000;%initial deposit
deposit = 500; %yearly deposit
APR = 0.04; %interest rate
years =[0:14]; %years of deposit
for years = years + 1
years < 15
principal = balance + (balance*APR)
balance =balance +deposit
fprintf ('After %d years the balance in your account will be $%.2f\n',years,balance);
end
fprintf('final balance after %dyears is $%.2f\n',years,balance);
Use a for loop in MATLAB to determine how much money you would have at your bank account in 15 years if you deposit $1000 initially and $500 at the end of each year, assuming the APR is 4%.

回答 (1 件)

Bhaskar R
Bhaskar R 2019 年 12 月 1 日
clear;
clc;
balance = 1000;%initial deposit
deposit = 500; %yearly deposit
APR = 0.04; %interest rate
% years =[0:14]; %years of deposit
for years = 0:14
principal = balance + (balance*APR);
balance =balance +deposit;
fprintf ('After %d years the balance in your account will be $%.2f\n',years,balance);
end
fprintf('final balance after %dyears is $%.2f\n',years,balance);

カテゴリ

Help Center および File ExchangeMATLAB についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by