In: Advanced Math
ICE13B - “How long will the money last?” You begin on 1 January 2015 by making an initial deposit of $5,000 to open a savings account at Bank of Mason. This account pays 0.135% interest per month. Every even numbered month, you withdraw $500 to pay your tuition installment balance. At the end of December each year you receive a $2,000 end-of-year bonus from your employer which you deposit into your account. Run your simulation until your account balance goes negative. Question 1: During what month does you account balance go negative after making the withdrawal? Question 2: Prepare a plot showing your account for all months A Matlab code is needed
%there would be no such months as the increment s more than what is being taken
%the following is the code which defines the provided logic but the balance never goes to negative and the loops runs infinitely
clear
clc
balance = 5000;
i=0;
while true
balance = balance + (0.135/100)*balance;%every
month, add interest
i = i+1;
if rem(i,7)==0
balance = balance -
500;%at the end of every 7 months, remove 500
end
if balance<0
break
end
if rem(i,12)==0%at the end of every 12 months,
add 2000
balance = balance +
2000;
end
end
fprintf('Month during which balance go negative: %d\n',i)
Chart.