Easier ways to write this scipt.
2 ビュー (過去 30 日間)
古いコメントを表示
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%.
0 件のコメント
回答 (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 = 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);
0 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!