Easier ways to write this scipt.
39 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (1)
Bhaskar R
el 1 de Dic. de 2019
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 comentarios
Ver también
Categorías
Más información sobre 2-D and 3-D Plots 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!