28 - When you borrow money to buy a house, a car, or for some other purpose, you
ID: 3567360 • Letter: 2
Question
28 - 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
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 . . .
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.