Question
Suppose you have taken out a loan that is to be repaid, with interest, in monthly installments. The amount due each month can be determined
Suppose you have taken out a loan that is to be repaid, with interest, in monthly installments. The amount due each month can be determined using the following formula:
where
= individual (monthly) payment
= principle (i.e., amount of loan)
i= interest rate (monthly)
= number of (monthly) payment periods
a. Define a function named monthlyPayment that takes 3 arguments as input: the amount of the loan, the annual interest rate (as a percentage), and the term of the loan (number of years), in that order. The first line of the functions should look like:
function payment = monthlyPayment(principle, interest, term)
You should assume that interest is the annual interest rate, given as a percentage (e.g., 4.75 and not 0.0475) and that term is the number of years the loan is for.
The function should return the monthly payment amount, calculated using the formula above. Note that your function will have to take into account the fact that values passed into the function are given in yearly amounts and the function needs to calculate the monthly payment. Make sure your function works correctly on vectors as well as scalars, i.e., make sure it works if principle, interest, and term are vectors containing the information for N loans (in which case it should return a vector of length N containing the monthly payment amounts).
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started