Please help..due at midnight and haven\'t fully gotten arrays down... Write a C
ID: 3825129 • Letter: P
Question
Please help..due at midnight and haven't fully gotten arrays down...
Explanation / Answer
#include <iostream.h>
#include <math.h>
#include <iomanip.h>
int main (void)
{
//Declare Variables
double principal, rate, mrate, mpay, factor, interest, balance;
int month, cnt;
//Program Title
cout << endl;
cout << "Loan Amortization Program ";
cout << endl;
//Input from User
cout << "What is the value of the loan? ";
cin >> principal;
cout << "What is the loan duration (in months)? ";
cin >> month;
cout << "What is the APR (Annual Percentage Rate)? ";
cin >> rate;
cout << endl;
//Calculation of Monthly Payment
mrate = (rate/1200);
factor = pow( (mrate+1), (month));
factor = (factor-1);
mpay = (mrate+(mrate/factor))*principal;
//Display Output to User
cout << "Loan Amortization Information: ";
cout << endl;
cout << "Intial Loan Value: $" << principal << " ";
cout << "Loan Duration: " << month << " months ";
cout << "Annual Percentage Rate: " << rate <<"% ";
cout << "Monthly Payment: $" << mpay << " ";
//Up to this point, everything works and is formatted correctly.
//Loop for Displaying Payment Information
cout << setw(5) << "Month" << setw(5) << "Starting Balance" <<
"Interest" << "Payment" << "New Balance" << endl;
cout << endl;
cnt = 1;
while (cnt <= (month-1))
{
setprecision(2);
interest = ((principal*(rate/100))/month);
cout << cnt << " " << principal << " " << interest << " " <<
mpay << " " << (principal = ((principal+interest)-mpay)) << endl;
cnt++;
}
interest = ((principal*(rate/100))/month);
cout << setprecision(2);
cout << month << " " << principal << " " << interest << " " << mpay <<
" " << (principal+interest) << " " << ((principal+interest)-mpay) <<
endl;
cout << endl;
return 0;
}