Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

home / study / engineering / computer science / computer science questions and a

ID: 3756278 • Letter: H

Question

home / study / engineering / computer science / computer science questions and answers / Please Answer All Parts And Provide All Code From C++. Programming Assignment 3 (length Of ...

Question: Please answer all parts and provide all code from C++. Programming Assignment 3 (length of mortga...

Please answer all parts and provide all code from C++.

Programming Assignment 3 (length of mortgage)

You have just secured a mortgage for a house that costs $240,000. The down payment is $40,000. The terms of the mortgage are that

1) the monthly payment is $1500 (if principle is >=1500), otherwise the monthly payment is whatever is left.

2) payments are 12 times a year at equally spaced intervals,

3) there are 365 days in a year,

4) the rate is 6 percent for the first 3 years and 7 percent afterwards.

Find the following: 1) How many months will it take to pay off the entire mortgage? 2) What is the final monthly payment?

Example: you borrow $100,000. Interest that accumulates in first year is 6 percent of this, which is $6,000.

Interest that accumulates in a month is 6 percent/12 percent, which is .5 percent of the principle ($100,000). This is $500.

Some questions and answers

Q:Is the interest being calculated annually as opposed to monthly?

A: To find the interest rate, divide the annual rate by 12 so this is 0.06/12 (for the first three years). Every month, the amount that you have borrowed, P, will grow and become P(1+0.06/12).

Q: Do we assume we are paying the interest amount first each month before we use the remainder to pay-down the principal?

A: Yes, you make payments at the first of every month. Thus, the first payment will be made when time t = 1. (You made the down payment when t = 0, where t is in months.)

Q: Describe the payment schedule.

A: You start with $200,000 debt. The debt accumulates for a month. Then you pay $1500. The debt accumulates on the remaining principle. You pay off $1500. And so on and so forth. When there is less than $1500, for example, $1000, then your last payment is this amount, in this case, $1000.

Explanation / Answer

ScreenShot

---------------------------------------------

Program

//Header files for I/O,and output manipulation
#include<iostream>
#include<string>
#include<iomanip>
using namespace std;
//Main method
int main()
{
   //Variable for calculation
   double principal = 240000, downPayment = 40000,monthlyPayment=1500;
   int counter = 0;
   double mortgage = principal - downPayment;
   double interestRate1 =.005, interestRate2 =(7/1200),interestAmount=0;
   //First 3 yrs calculation
   while (mortgage > 1500) {
           for (int t = 1; t <= 12; t++) {
               interestAmount = mortgage * interestRate1;
               mortgage = mortgage - (monthlyPayment - interestAmount);
               counter++;
               //cout << counter << " " << mortgage <<" "<< interestAmount << endl;
               if (mortgage <= 1500 || counter <= 36) {
                   break;
               }
           }
       }
   //After 3 yrs calculation
   while (mortgage > 1500) {
       for (int t = 1; t <= 12; t++) {
           interestAmount = mortgage * interestRate2;
           mortgage = mortgage - (monthlyPayment - interestAmount);
           counter++;
           //cout << counter << " " << mortgage <<" "<< interestAmount << endl;
           if (mortgage <= 1500) {
               break;
           }

       }
   }
   //Display result
       cout << "Final month payment= $" << fixed << setprecision(2) << mortgage << endl;
       cout << "Number of months needed to complete mortgage= " << counter+1 << endl;
    return 0;
}

------------------------------------------

Output

Final month payment= $405.67
Number of months needed to complete mortgage= 221
Press any key to continue . . .