Credit Card A bank sends credit card statements to customers each month with the
ID: 3597965 • Letter: C
Question
Credit Card A bank sends credit card statements to customers each month with the option of paying a percentage of the outsanding balance that month. If a customer continue to have an outstanding balance on the account after paying a percentage of the monthly outsanding balance, the bank applies monthly interest to their debt Write a function CreditCard to calculate outstanding debt on a credit card after a given constant percentage of the outstanding balance is paid. The input to the function CreditCard is the initial balance, initBal, the annual percentage interest rate, annuallnterestRate, percentage of the outstanding balance that will be paid, percentPaid, and the number of months numberMonths the loan has been active. The outputs are the outstanding balance, outstandingBalance, and the amount that was aready paid by the credit card holder, totalAmountPaid Restriction: Use for loops in the CreditCard Hint: The monthly interest rate is 1/12 of the annual interest rate. For example, the following script, which uses the function CreditCard. The initial balance uis $3000, the annual interest percentage is 10%, the percentage of the outstanding balance that will be paid is 2% and the loan the loan has been active has been active for 12 months number of months, given that every month a >>format bank; >>[ outstand ingBalance, totalAmountPaid] = CreditCard ( 3000, 10, 2, 12) produces the result: outstand!ngBalance = 2600.66 totalAmountPaid = 674.94 Your Function Save C Reset MATLAB Documentation 1 function [ outstandingBalance, totalAmountPaid] = Creditcard ( initBal, annual!nterestPercentage, monthlyPaymentPercentage, numberMonths) 4 6 Trouble with lab?Explanation / Answer
in file CreditCard.m
function [ outstandingBalance, totalAmountPaid] = CreditCard(initBal, annualInterestPercentage, monthlyPaymentPercentage, numberOfMonths)
outstandingBalance = initBal;
totalAmountPaid = 0;
monthlyinterest = annualInterestPercentage/12;
for i = 1:numberOfMonths
amountPaid = (outstandingBalance)*monthlyPaymentPercentage/100;
totalAmountPaid = totalAmountPaid + amountPaid;
outstandingBalance = outstandingBalance - amountPaid;
outstandingBalance = outstandingBalance*(1+monthlyinterest/100);
end
end
on console
[ outstandingBalance, totalAmountPaid] = CreditCard(3000,10,2,12)
Sample execution:
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.