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

Write a C++ program to do the following. Prompt and get the user inputs for prin

ID: 3550420 • Letter: W

Question

Write a C++ program to do the following. Prompt and get the user inputs for principal loan amount, interest rate(as %) and the monthly payment. Divide the interest rate by 100.0 (For example, if the user entered 4 for 4%, 4/100 = 0.04), then by 12 to get the monthly interest rate. Here are the formulas for monthly computation:

monthly interest = principal * monthly interest rate

payment towards principal = monthly payment - monthly interest

principal = principal - payment towards prinicipal

output month #, monthly interest, payment towards principal, remaining principal.

increment month #

Repeat the above steps until the principal reaches 0. You may need additional adjustments for the final month since the payment may be small amount.

Primary goal of this weekly activity is to use the formatting mechanisms (setw(), setprecision(), fixed,

Explanation / Answer

please rate - thanks'




#include <iostream>
#include <iomanip>
using namespace std;
int main()
{double principal, payment, rate,interest,principalPayment;
int month=0;
cout<<"Enter the loan amount: ";
cin>>principal;
cout<<"Enter the yearly interest rate: ";
cin>>rate;
cout<<"Enter the monthly payment: ";
cin>>payment;
rate=rate/100./12.;
cout<<"                        payment ";
cout<<"payment   monthly       towards          new ";
cout<<"number    interest      principal     principal ";
cout<<"             $              $              $ ";
cout<<setprecision(2)<<fixed;
while(payment<principal)
{month++;
interest=principal*rate;
principalPayment=payment-interest;
principal=principal-principalPayment;
cout<<setw(6)<<month<<setw(12)<<interest<<setw(14)<<principalPayment<<
      setw(15)<<principal<<endl;
}
month++;
interest=principal*rate;
principalPayment=principal-interest;
principal=principal-(principalPayment+interest);
cout<<setw(6)<<month<<setw(12)<<interest<<setw(14)<<principalPayment<<
      setw(15)<<principal<<endl;
system("pause");
return 0;
}


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