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

Kim wants to buy a car. Help Kim compute the monthly payment on a loan, given th

ID: 3684578 • Letter: K

Question

Kim wants to buy a car. Help Kim compute the monthly payment on a loan,
given the loan amount, the annual percentage rate of interest, and the number of monthly payments. The program should allow Kim to input the loan
amount, interest rate, and how many payments she wants to make. It should
then compute and display the monthly payment.
You will need the following variables:
Payment LoanAmt InterestRate
MonthlyRate NumberMonths
You will need the following formulas:
MonthlyRate = InterestRate/1200
Note: when the user enters InterestRate as a percentage, it must be divided
by 100 to make it a decimal (i.e., 18% = 18/100 = 0.18). The InterestRate
offered by car dealers is an annual rate so this must be divided by 12 to get
the MonthlyRate. The formula given above combines the two steps (i.e.,
annual rate of 18% = 18/100 = 0.18 and the monthly rate is 0.18/12 =
0.015 or 18/(100*12) = 18/1200.
Payment = LoanAmt * MonthlyRate * (1 +
MonthlyRate)^NumberMonths ÷ ((1 +
MonthlyRate)^NumberMonths – 1)
Note: The formula must be entered carefully, exactly as shown.

Explanation / Answer

#include<iostream>
using namespace std;

int main(){

   double Payment, LoanAmt, InterestRate, MonthlyRate, NumberMonths;
  
   cout<<"Enter loan amount:: ";
   cin>>LoanAmt;
   cout<<"Enter Interest rate: ";
   cin>>InterestRate;
   cout<<"Enter Number of payments you want to make: ";
   cin>>NumberMonths;
  
   MonthlyRate = InterestRate/1200;
  
   // calculating (1+MonthlyRate)^NumberMonths
   double temp = 1;
   for(int i=1; i<=NumberMonths; i++){
       temp = temp*(1+MonthlyRate);
   }
  
   Payment = (LoanAmt*MonthlyRate*temp)/(temp-1);
  
   cout<<"Payment amount per month: "<<Payment<<endl;
  
   return 0;
}