Problem 2 (20 Points) Consider a user-defined function that calculates an amount
ID: 3775761 • Letter: P
Question
Problem 2 (20 Points) Consider a user-defined function that calculates an amount of money, invested saving account year. Your function takes inputs: the initial balance and the annual interest rate. The returns two outputs: the interest and the final In the box below, write a function file, bank m, consisting of the following variables xo the initial balance, in dollars the annual interest rate, in percentage i the interest, in dollars xf the final balance, in dollars Let's consider an example. Suppose s200 is invested in an account that generates 6% interest. Because 6% of S200 is $12.00, the balance after one year is $200 $12- $212.00. How could we use the bank function-along with the input values 200 and 6-to perform the calculation just described? Your command line must be consistent with the response, shown below. interest Page 1 of 4Explanation / Answer
initial_balance = input('initial_balance');
annual_intrestrate = input('annual_intrestrate');
[intr,xf] = bank(initial_balance,annual_intrestrate);
function [intr,xf] = bank(initial_balance,annual_intrestrate)
% Interest calculation.
intr = (initial_balance * annual_intrestrate) /100;
xf = initial_balance + intr;
disp('_______________________');
disp('intrest = ');
disp(intr);
disp('balance = ');
disp(xf);
end