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

For a loan or a morgage we repay by monthly(periodic) payments. L = loan amount

ID: 3624403 • Letter: F

Question

For a loan or a morgage we repay by monthly(periodic) payments.
L = loan amount
r = Interest rate per year
m = number of payments in a year
t = the loan for (t) years

Suppose that i = (r/m) then the monthly payment is:


          L*i
R = ----------------
      1 - (1+i) ^ -mt



Also we can figure out the unpaid balance.
For example the unpaid balance after making k payments.

           1 - (1+i)^ -(mt-k)
L =R* ( ---------------------)
                      i

Where R is the monthly(periodic) payment.

-Write a program that prompts the user to input the values of L, r, m, t, and k.
The program then outputs the appropiate values.
-The program must contain two function with the right parameters, to calculate the monthly payment and balance due after some payments.
-Make the program menu drive and use a loop so that the user can repeat the program for different values.

 

 

 

Thanks

Explanation / Answer

#include <math.h>

using namespace std;

//Mortgage class

class Mortgage

{

     double loan,rate,year,payment,term;

     public:

          //setting loan amount

          void setloan(double l)

          {

              loan=l;

          }

          //setting interest rate

          void setrate(double r)

          {

              rate=r;

          }

          //setting number of years2

          void setyear(double y)

          {

              year=y;

          }

          //calculating monthly and yearly payment function

          void monthpay()

              payment=(loan*(rate/12)*term)/(term-1);

              cout<<"Monthly payment is:"<<payment<<endl;

      cout<<"Total amount paid to the bank at the end of the loan period :"<<(payment*12*year)<<endl;

          }

};

//main function

int main()

{

     Mortgage m;

     double loan,rate,year;

     cout<<"Enter the loan amount (in dollars) :"<<endl;

     cin>>loan;

     cout<<"Enter the annual interest rate :"<<endl;

     cin>>rate;

     cout<<"Enter the number of years of the loan :"<<endl;

     cin>>year;

     m.setloan(loan);m.setrate(rate);m.setyear(year);

     m.monthpay();

    system("pause");

}

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