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

Please answer in a matlab script As you make decisions over your 401K, you find

ID: 3209953 • Letter: P

Question

Please answer in a matlab script
As you make decisions over your 401K, you find one investment opportunity that will draw 12% interest per year added to your account. The trick to 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 deposit which can be any amount between $5500-$8500. You will receive statements of the balance for the total years you have invested until the balance is doubled.
Expected from this program:
Initialize balence, year, and interest rate. Your first year is denominated at year 0.
You will need to display the balance with headings “Year” and “Balence 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 etc.
Please answer in a matlab script
As you make decisions over your 401K, you find one investment opportunity that will draw 12% interest per year added to your account. The trick to 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 deposit which can be any amount between $5500-$8500. You will receive statements of the balance for the total years you have invested until the balance is doubled.
Expected from this program:
Initialize balence, year, and interest rate. Your first year is denominated at year 0.
You will need to display the balance with headings “Year” and “Balence 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 etc.

As you make decisions over your 401K, you find one investment opportunity that will draw 12% interest per year added to your account. The trick to 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 deposit which can be any amount between $5500-$8500. You will receive statements of the balance for the total years you have invested until the balance is doubled.
Expected from this program:
Initialize balence, year, and interest rate. Your first year is denominated at year 0.
You will need to display the balance with headings “Year” and “Balence 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 etc.

Explanation / Answer

balance = 4500.00;
year = 1;
rate = 0.12;
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 5040.00
2.00 5644.8
3.00 6322.17

%}