I need help for calculating mortgage for a homework problem
11 views (last 30 days)
Show older comments
Jonathan Monnat
on 18 Nov 2020
Commented: Jonathan Monnat
on 18 Nov 2020
Here is the question:
If you take out a mortgage to pay for a $100,000.00 house, how much does it actually cost to make all the payments on the mortgage? Assume a 30-year mortgage at an annual interest rate of 3.92% and a monthly payment of $473.00. Use a while loop to calculate the following:
a. Amount of each monthly payment covering interest (going to change each month!)
b. Amount of each monthly payment covering principle (going to change each month!)
c. Create the following plots
i: Figure 1 – remaining principle as a function of time
ii. Figure 2 – principle and interest covered in individual payments (from a and b above) as a function of time (so two curves on one plot)
iii. Figure 3 – total principle paid off, total interest cost, and total mortgage cost as a function of time.
I need help on completing this matlab code for using a while loop. My constants so far are...
P = 100000; % Principal starting amount
M = 473; % monthly payments
i = 0.00326666; % monthly interest
Truthfully, you don't have to do the graphs for the problem, I can figure those out once the main code and while loop is completed.
Thanks in advance!!!
4 Comments
Accepted Answer
More Answers (1)
James Tursa
on 18 Nov 2020
Edited: James Tursa
on 18 Nov 2020
OK, so ask yourself what has to happen every month? You get charged interest and you make a payment, right? And you are told to use a while loop. So I would assume your instructor wants something like this:
k = 1;
while( P > 0 )
interest = ___; % calculate the monthly interest on P here
payment = ___; % amount you are paying this month
payment_principle = ___; % amount of payment that is used for paying down the principle
P = ___; % calculate the new principle value
% other code to save the values you will be plotting later (using index k)
k = k + 1; % increment the index
end
% plot stuff here
You fill in the blanks and then generate your plots. The k is intended to be used as an index into the vectors you will be creating to save the information you will be plotting.
0 Comments
See Also
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!