In: Mechanical Engineering
Use a loop in MATLAB to determine how long it will take to accumulate $1 000 000 in a bank account if you deposit $10 000 initially and $10 000 at the end of each year; the account pays 6 percent annual interest.
It is required to determine how long will it take to accumulate $1,000,000 with 6% annual interest. Initially $10,000 is deposited and $10,000 is deposited at the end of each year.
A while loop is to be created in this case as the number of iterations are not fixed. We need to find out number of iterations required.
The MATLAB code is given below. We have to initialize a variable that will represent the year. Then on each successive iteration the amount is calculated and checked with the limit given in question.
Input:
%initializing the year
k = 0;
Amount = 10000;
while Amount < 1000000
k = k + 1;
%calculating amount at each successive year
Amount = 1.06*Amount + 10000;
end
Amount
k
Output:
Amount = 1.0418e+06
k = 33
We see that it will take 33 years to accumulate $1,041,800.
We see that it will take 33 years to accumulate $1,041,800.