Question: Program language C++. Using fstream, cmath, iostream, iomanip only The formula for determining the monthly payment (p) for a mortgage is: p = m*[ ((1
Program language C++.
Using fstream, cmath, iostream, iomanip only
The formula for determining the monthly payment (p) for a mortgage is:
p = m*[ ((1 + r/12 )^12n) * r/12] / [ ((1+r/12)^12n ) -1]
where m is the amount of the loan, r is the annual interest rate in decimal form, and n is the number of years in the mortgage. For example, a 30-year loan for $500,000 at 4.5% (i.e., r = .045) results in a monthly payment of $2,533.43 rounded to the nearest cent.
Write a program that obtains (from the user) the amount (>=1000), interest rate as a percentage (from 1.5% to 15% ), the number of years of the loan (>=2).
Program first calculates the monthly payment and rounds this payment to the nearest dollar.
The program also loops to produce an amortization table that shows the initial amount of the load, the annual interest rate and the term of the loan in the heading. In the body of the table it shows the amount paid to principal at the end of each month, the amount paid to interest, and the amount of the loan still owed. This table is written to a text file.
Here is an example with all amounts are rounded to nearest dollar.
Sample run screen, with user entries shown here in BOLD ITALIC:
Loan amount over $1,000: 30000
Annual interest rate as a percentage from 1.5% to 15%: 5.25
Number of years (2 or more): 4
The monthly payment is $694
The total amount to be repaid over 4 years is $33,326
The total interest paid will be $3,326
Here is what goes into the text file:
Car Loan for $30,000 paid over 4 years at 5.25%..
Monthly Payment: $694
| End of Month | Interest Paid |
Principal Paid
| Amount Owed |
| 1 | $131 | $563 | $29,437 |
| 2 | $129 | $565 | $28,871 |
| 3 | $126 | $568 | $28,304 |
| 4 | $124 | $570 | $27,733 |
| 5 | $121 | $573 | $27,160 |
| 6 | $119 | $575 | $26,585 |
| 7 | $116 | $578 | $26,007 |
| 8 | $114 | $581 | $25,426 |
| (I did not | show | all cells | here |
|
|
|
|
|
| 44 | $15 | $679 | $2,747 |
| 45 | $12 | $682 | $2,065 |
| 46 | $9 | $685 | $1,380 |
| 47 | $6 | $688 | $691 |
| 48 | $3 | $691 | $0 |
| Total Paid | $3,326 | $30,000 | $33,326 |
Test your program with the values in the sample run shown above as well as the required test cases shown below.
Mortgage is $500,000, rate is 4.5% and term is 15 years.
Mortgage is $350,000, rate is 4.5% and term is 30 years.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
