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

When you borrow money to buy a house, a car, or for some other purpose, you repa

ID: 3529768 • Letter: W

Question

When you borrow money to buy a house, a car, or for some other purpose, you repay the loan by making periodic payments over a certain period of time. Of course, the lending company will charge interest on the loan. Every periodic payment consists of the interest on the loan and the payment toward the principal amount. To be specific, suppose that you borrow $1000 at the interest rate of 7.2% per year and the payments are monthly. Suppose that your monthly payment is $25. Now, the interest is 7.2% per year and the payments are monthly, so the interest rate per month is 7.2/12=0.6%. The first month;s interest on $1000 is 1000 * 0.006=6. Because the payment is $25 and interest for the first month is $6, the payment toward the principal amount is 25-6=19. This means after making the first payment, the loan amount is 1000-19=981. For the second payment, the interest is calculated on $981. So the interest for the second month is 981 * 0.006=5.886, that is, approximately $5.89. This implies that the payment toward the principal is 25-5.89=19.11 and remaining balance after the second payment is 981-19.11=961.89. This process is repeated until the loan is paid. Write a program that accepts as input the loan amount, the interest rate per year, and the montly payment. (Enter the interest rate as a percentage. For example, if the interest rate is 7.2% per year, then enter 7.2) The program then outputs the number of months it would take to repay the loan. (Note that if the monthly payment is less than the first month's interest, then after each payment, the loan amount will increase. In this case, the program must warn the borrower that the monthly payment is too low, and with this payment, the loan amount could not be repaid.) Do Problem 19 on pages 323-324 of your textbook (see Problem above). You program should take its inputs from input dialog boxes and send the number of months to an output dialog box. In addition, your program should output the loan amortization table in an output file. An example amortization table (partial) is shown below: Month/year. Payment Principle paid Interest paid. Total interest. Balance Mar. 2013 $1,483.07 $520.57 $962.50 $962.50 $164,479.43 April 2013 $1,483.07 $523.60 $959.46 $1,921.96 $163,955.83 May 2013. $1,483.07 $526.66 $.956.41 $2,878.37 $163,429.17 June 2013 $1,483.07 $529.73 $.953.34 $3,831.71 $162,899.44 July 2013 $1,483.07 $532.82 $.950.25 $4,781.96 $162,366.62 Aug. 2013 $1,483.07 $535.93 $.947.14 $5,729.09 $161,830.69 Sept. 2013 $1,483.07 $539.05 $944.01 $6,673.11 $161,291.64 Please use eclipse to do the assignment

Explanation / Answer

Program code:

// LoanPayment.cpp

#include <iostream>

using namespace std;

//main function

int main()

{

     //declare the required variables

     double loanborrow;

     double monthlyamount;

     double rate,rpm;

     double interest=0;

     double principal;

     //prompt the user to enter the respective info as asked

     cout<<"Enter the loan borrowed: $";

     cin>>loanborrow;

     cout<<"Enter the rate of interest per year: ";

     cin>>rate;

     cout<<"Enter monthly pay: $";

     cin>>monthlyamount;

     //calculate the rate per month

     rpm=(rate/12.0)/100;

     //declare the count variable

     //that inimates the number of years

     int count=0;

     //execute a loop until the loan if ful filled

     while(loanborrow>=0)

     {

          //condition to check whether the monthly

          //pay is less than interest

          if(monthlyamount>interest)

          {

              //if the condition is true,

              //then execute the following statements

              interest=loanborrow*rpm;

              principal=monthlyamount-interest;

              loanborrow=loanborrow-principal;

              count++;

          }

          //if the condition is false

          //display the below information

          else

          {

              cout<<"Monthly pay is too low than the interest."

                   <<"The loan cannot be recovered."<<endl;

          }

     }

     cout<<"In "<<count<<" months the loan will be repaid."<<endl;

     system("pause");

     return 0;

}

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

Sample Output:

Enter the loan borrowed: $1000

Enter the rate of interest per year: 7.2

Enter monthly pay: $25

In 46 months the loan will be repaid.

Press any key to continue . . .

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote