% Bank_Balance_For.m - Greg Bucks - 10/8/2013
% Description: this script will compute the balance of a bank account after
% 10 years, assuming an initial deposit of $1000, and monthly deposit of
% $500, and an annual interest rate of 5% compounded monthly.
% Usage: >> Bank_Balance_For;

% set up initial values
account_value = 1000;           % initial deposit
monthly_deposit = 500;          % monthly deposit
annual_rate = 0.05;             % annual interest rate
monthly_rate = annual_rate/12;  % monthly rate
duration = 10;                  % number of years

% determine value in account after 10 years
for k = 1:duration*12
    account_value = account_value + monthly_deposit + monthly_rate*account_value;
end

% display result
fprintf('The value in the account after %d years is $%0.2f.\n',duration,account_value);