2.25 A plumber opens a savings account with $100,000 at the beginning of January
ID: 3724268 • Letter: 2
Question
2.25 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 110000: 110 000 1 25 000: 1% 1.5% 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.)Explanation / Answer
ScreenShot:-
------------------------------------------------------------------------------------------------------------------------------------
Program:-
deposit=100000; %Initialize deposit=100000
fprintf('MONTH InterestRate InterestAmount NewBalance ') %to print heading
fprintf('--------------------------------------------------------------------- ')
%loop for getting each month and interest calculations
for m=1:12
%if deposit less than 1100000 then print month interest interest amount anf new balance accordingly
if deposit<=110000
interest=0.01;
iAmount=deposit*interest;
deposit+=iAmount;
%if deposit less than 1250000 then print month interest interest amount anf new balance accordingly
elseif deposit>110000 & deposit<=125000
interest=0.015;
iAmount=deposit*interest;
deposit+=iAmount;
%if deposit greater than 1250000 then print month interest interest amount anf new balance accordingly
else
interest=0.02;
iAmount=deposit*interest;
deposit+=iAmount;
end
%add 1000 every month end
deposit+=1000;
%print result
fprintf(' %d %d %d %d ',m,interest,iAmount,deposit)
end
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.