Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

using MATLAB: Problem #1: As you make decisions over your 401K, you find one inv

ID: 3836582 • Letter: U

Question

using MATLAB:

Problem #1: As you make decisions over your 401K, you find one investment opportunity that will draw 9% interest per year added to your account. The trick about this investment is that you will need to cancel the investment as soon as you double the amount of money you put in the first time which could be any amount from $1000 - $3500. You will received statements of the balanced for the total years you invested until the balanced is doubled.

Expected from this program:

• Initialize balance, year, and interest rate. Your first year is denominated at year 0.

• You will need to display the balance with headings “Year” and “Balance” until the balance is twice the original.

• Please display the numbers with bank format

Example:
Initial Balance=4500.00

Year     Balance

1.00       4905.00

2.00       5346.45

3.00       5827.63

4.00       6352.12

5.00       6923.81

6.00       7546.95

7.00       8226.18

8.00       8966.53

9.00       9773.52

Explanation / Answer

%matlab code

balance = 4500.00;
year = 1;
rate = 0.09;
fprintf('Initial Balance = %0.2f ',balance);
initialBalance = balance;
fprintf('Year Balance ');
while true
  
nextbalance = balance + balance*rate;
fprintf('%0.2f %0.2f ',year,nextbalance);
  
if nextbalance >= (2*initialBalance)
break;
end
  
balance = nextbalance;
year = year + 1;
  
end

%{
output:

Initial Balance = 4500.00
Year Balance
1.00 4905.00
2.00 5346.45
3.00 5827.63
4.00 6352.12
5.00 6923.81
6.00 7546.95
7.00 8226.18
8.00 8966.53
9.00 9773.52

%}