MATLAB: Nested if/else loop not stepping through all steps; why

if/else loops

Here is the problem I'm working on:
====================
A plumber opens a savings account with $100,000 at the beginning of January. He then
makes a deposit of $1000 at the end of each month for the next 12 months (starting at
the end of January). Interest is calculated and added to his account at the end of each
month (before the $1000 deposit is made). The monthly interest rate depends on the
amount A in his account at the time interest is calculated, in the following way:
A ≤ 1 10 000 : 1%


1 10 000 < A 1 25 000 : 1.5%
A > 1 25 000 : 2%
Write a program that displays, under suitable headings, for each of the 12 months, the
situation at the end of the month as follows: the number of the month, the interest rate,
the amount of interest, and the new balance. (Answer:Values in the last row of output
should be 12, 0.02, 2534.58, 130263.78).
====================
For now I'm ignoring the fact that interest is compounded BEFORE the monthly $1000 deposit and assuming it happens after. Here is my script:
====================
A=100000;
Monthly=1000;
Months=[1:12];
disp('MONTHS ELAPSED INTEREST RATE AMOUNT OF INTEREST MONTH-END BALANCE')
for k=1:length(Months)
if A <= 110000;
rate=1.01;
elseif A <=125000;
rate=1.015;
else A>125000;
rate=1.02;
end
Interest=((A+Monthly)*rate)-(A+Monthly);
A=(A+Monthly)*rate;
disp([Months(k)' rate'-1 Interest' A'])
end
====================
My output looks like this. Some of the calculations are wrong, but what I'm currently trying to figure out is why the interest rate goes from 0.01 to 0.02, never to 0.015. The book I'm using says that with relational operators in if/else statements, as soon as it encounters a true 'if' statement it skips down and goes back to the top again. How can this be possible if the values between 110000 and 125000 are never assigned to rate=0.015?
====================
MONTHS ELAPSED INTEREST RATE AMOUNT OF INTEREST MONTH-END BALANCE
1.00 0.01 1010.00 102010.00
2.00 0.01 1030.10 104040.10
3.00 0.01 1050.40 106090.50
4.00 0.01 1070.91 108161.41
5.00 0.01 1091.61 110253.02
6.00 0.01 1668.80 112921.82
7.00 0.01 1708.83 115630.64
8.00 0.01 1749.46 118380.10
9.00 0.01 1790.70 121170.80
10.00 0.01 1832.56 124003.37
11.00 0.01 1875.05 126878.42
12.00 0.02 2557.57 130435.98

Best Answer

The interest rates are calculated right. The issue is that 0.015 gets hidden as 0.01.
Try this instead of disp:
fprintf('%d \t %1.3f \t %7.1f \t %7.1f \n',Months(k),rate-1,Interest,A)