Question: Write two m - file functions that will allow you to compare mortgage calculations for the monthly payment and compare mortgages with different loan values.
Write two mfile functions that will allow you to compare mortgage calculations for the monthly
payment and compare mortgages with different loan values.
The monthly payment is calculated using:
Where is the principal loan amount, is the interest rate in decimal form not percent form and Is the number of years of the loan.
a Create an mfile function called "mortgageam that will serve as a loan calculator like the
ones you might find online This function will have three inputs and two outputs. The three
inputs in order are mortgage amount in Dollars interest rate in and years to pay off the
loan in years The outputs will be in the order returned: monthly payment and total of all
payments. If the Term is not input, it is assumed to be years. An example output of the
function is shown in Figure Note: Your function will be checked with other input values whe graded.
mortgage
Figure : Loan Calculator Script Input and Output
b Create a second file function called "mor ryagebm that will allow you to compare
different loan amounts. This function will have two inputs and no outputs. The two inputs in
order are: the maximum mortgage amount in Dollars and interest rate in You can modif your file from part a for this script. Although the function does not return any values, it will
output a Table in the Command Window. Your script needs to create a loan amount vector with
a range of loan amounts principal from the maximum mortgage amount down to $ less in principal in $ increments. Calculate the monthly payments for both and year
payback plans based on the varying initial amounts for the principal. An example of the
truncated output is shown in Figure for a maximum mortgage amount of $ and an
interest rate of This is example output and your function should give correct values for
other inputs.
Figure : Loan Calculator Table Script Input and Output Format
Note: The output should continue subtracting $ from the principal on each new row until it
has subtracted $ from the cost of the house. The decimals on principals and payments should all line up for principals up to $ Your function should still have all the dollar signs in the Table aligned for larger or smaller loan amounts.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
