For loops: Savings account The for loop calculates the amount of money in a savings account after numberYears given an initial balace of savingsBalance and an annual interest rate of 2.5%. Complete the for loop to iterate from 1 to numberYears (inclusive). Function Save Reset MATLAB DocumentationOpens in new tab function savingsBalance = CalculateBalance(numberYears, savingsBalance) % numberYears: Number of years that interest is applied to savings % savingsBalance: Initial savings in dollars interestRate = 0.025; % 2.5 percent annual interest rate % Complete the for loop to iterate from 1 to numberYears (inclusive) for ( ) savingsBalance = savingsBalance + (savingsBalance * interestRate); end end 1 2 3 4 5 6 7 8 9 10 11 12 Code to call your function

Respuesta :

Answer:

Desired MATLAB code is explained below

Explanation:

function savingsBalance = CalculateBalance(numberYears, savingsBalance)

% numberYears: Number of years that interest is applied to savings

% savingsBalance: Initial savings in dollars

interestRate = 0.025; % 2.5 percent annual interest rate

 

% Complete the for loop to iterate from 1 to numberYears (inclusive)

for (i = 1 : numberYears)

savingsBalance = savingsBalance + (savingsBalance * interestRate);

end

end