How to calculate the compound interest (compounded every 3 months) withh annual bonus if the balance is more than a certain amount.

2 views (last 30 days)
Find the savings growth for a scheme whereby you are paid annual interest of 2.45%, compounded every 3 months, with an annual bonus of £40 if the total invested is over £3,000. The initial investment is £2500 and is invested for 12 years. What are the final savings (to 2 decimal places)?
Here is my code:
x=input('initial amount ');
p=input('number of years ');
m=p*4; %%dealing with 3 months period instead of years
%%for easier compound interest calculations
for k=1:m;
intereset_every_3_month=x*(0.6125/100);
x=intereset_every_3_month+x;
if k==4 || k==8 || k==12 || k==16 || k==20 || k==24 || k==28 || k==32 || k==36 || k==40 || k==44 || k==48
if x>3000
x=x+40;
end
end
disp(round(x));
disp(intereset_every_3_month);
end
The conditional using the or operator is to ensure that the increase is only applied annually (every 4*3 months period)
My answer is 3562, however the correct answer is 3517. Am I doing something wrong here?
  1 Comment
dpb
dpb on 3 Dec 2013
Edited: dpb on 3 Dec 2013
Crudely (ignoring the partial year in which the 3000 threshold was crossed) I got 3521 so since the desired answer is given as 3517 I'd suspect it's correct.
I'd rewrite on r=r_input/4; and loop until total >3000, then use the additive term.
Alternatively, being an engineer and if only looking to get the right answer, solve for M=month_exceed_3k, then use the power formula
t=t*(1+r)^M; % first M months
t=(t+40)^(48-M); % remaining
:)

Sign in to comment.

Answers (0)

Categories

Find more on Introduction to Installation and Licensing in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!