the following 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).



Answer :

The loop will be written in Matlab.

Simply setting the years' range will allow the for loop to run its course and complete the task. To allow the loop to iterate from 1 to the number of years, we add the expression 1:number years.

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 n = 1:numberYears

savingsBalance = savingsBalance + (savingsBalance * interestRate);

end

end

Read more about Matlab on:

https://brainly.com/question/15071644

#SPJ4