ENGR 200 SPRING 2017 P9: MORTGAGE PAYMENTS (one-dimensional matrix in MATLAB) DU
ID: 3821147 • Letter: E
Question
ENGR 200 SPRING 2017
P9: MORTGAGE PAYMENTS
(one-dimensional matrix in MATLAB)
DUE: April 25, 2017 by 11:59 p.m. CT (Extra Credit)
April 27, 2017 by 11:59 p.m. CT (Final Deadline) POINTS: 30
INTRODUCTION:
House payments are typically based on a uniform payment series, in which the payment made every month is of the same amount. When a mortgage is taken out from the bank or other lender, the money is essentially “rented”; interest may be thought of as this rental rate. Therefore, the principal (the amount borrowed) and the interest must be paid back to the lending agency. The monthly payment rate, A, may be found from the following equation:
A = P * ( ( i x (1 + i)^n) / (1+i)^n - 1))
where P is the principal, i is the interest rate (5% = 0.05), and n is the number of payments made. For a 15-year mortgage, there would be 180 payments; for a 30-year mortgage, there would be 360 payments.
ASSIGNMENT:
Write a MATLAB script that will calculate the monthly payment for interest rates ranging from 0.25% to 5% in 0.25% increments. The program will prompt the user to enter the principal in dollars and the number of years. Use the following prompts in your script:
‘Enter principal in dollars: ’
‘Enter number of years: ’
You will need to convert from number of years to number of months.
The output report will be printed in MATLAB’s Command Window.
Before running your MATLAB program, do the following setup:
Set the Command Window screen format by selecting:
Preferences, Command Window
Numeric Format: short g
Numeric Display: loose
Tab Size: 0
Apply, OK
If needed, expand the Command Window to full screen before executing your program.
OUTPUT TABLE FORMAT:
****************************************************
MORTGAGE PAYMENT CALCULATIONS
Principal = $xxxxxx
Interest Rate Monthly Payment
x.xx xxxx.xx
x.xx xxxx.xx
x.xx xxxx.xx
x.xx xxxx.xx
****************************************************
HEADER:
Your script file should have a three-line header (commented code). The first line should be “Homework 9”, the second line should be your name, and the third line (and fourth, if needed) should be a one-sentence description of the program.
FILE NAME:
The naming convention that was used for C programs cannot be used in MATLAB. Before submitting to Blackboard, name your MATLAB program P9_sn_firstname_lastname, where sn is your section number.
Explanation / Answer
Please change the formula for A as needed as the one mentioned above is not clear in line 15. Also check the initial value of n=0 or 1 which is also not clear in the question. Here is the code:
P = input("Enter principal in dollars: ");
%Y = input("Enter number of years: ");
%M = Y*12;
M=2;
disp(" MORTGAGE PAYMENT CALCULATIONS")
temp = sprintf(' Principal = $%d ',P);
disp(temp)
temp = sprintf('Interest Rate Monthly Payment');
disp(temp)
i_output = 0.25;
i = 0.0025;
n = 0;
for m=1:M
A = P;
temp = sprintf('%.2f %.2f',i_output,A);
disp(temp)
i = i + 0.0025;
i_output = i_output + 0.25;
n=n+1;
end
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.