I need help for calculating mortgage for a homework problem
10 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Jonathan Monnat
el 18 de Nov. de 2020
Comentada: Jonathan Monnat
el 18 de Nov. de 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 comentarios
Respuesta aceptada
Más respuestas (1)
James Tursa
el 18 de Nov. de 2020
Editada: James Tursa
el 18 de Nov. de 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 comentarios
Ver también
Categorías
Más información sobre Loops and Conditional Statements en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!