Can someone please help me with this?? I have created this amortization schedule, it works fine displays great and shows the payment amount. However, i cannot get it to subtract the principal payment, interest payment, or get it to subtract from the principal amount each month. HELP.
Thanks,
//*Design
//This program calculates the monthly payment based on
//loan amount, annual interest rate, and the length of the
//loan in years. The user will enter amount of the loan
//annual interest rate, and duration of the loan. This program
//will also display an amortization schedule.
#include <iostream>
#include <iomanip>
#include <math.h>
using namespace std;
int main ()
{
double principal_amount = 0;
double rate =0;
int years;
double total_payments = 0;
double monthly_payment = 0;
double payment_interest = 0;
double payment_principal= 0;
double amount_owed = 0;
double intRate = 0;
int i = 1;
do
{
cout << " Enter Principal of loan: ";
cin >> principal_amount;
cout << " Enter yearly interest rate: ";
cin >> intRate;
cout << " Enter Duration of Loan: ";
cin >> years;
//Calculate monthly payment.
rate = (intRate /1200);
total_payments = (years * 12);
monthly_payment = (rate + ((rate/((pow(1+rate, total_payments))1)))) * principal_amount;
payment_interest = (rate /1200) * principal_amount;
payment_principal = (monthly_payment  payment_interest);
amount_owed = (principal_amount  payment_principal);
//Display monthly payment.
cout << " The monthly payment is " << monthly_payment << ". \n";
cout << " Payment # " << setw(12) << " Payment " << setw(12) << " PaymentInterest " << setw(12) << " PaymentPrincipal " << setw(12) << " Amt Owed " << endl;
(i = 0; i < (years * 12); i++)
{
monthly_payment = (rate + ((rate/((pow(1+rate, total_payments))1)))) * principal_amount;
payment_interest = ((rate /100)*(1/12))*principal_amount;
payment_principal = (monthly_payment  payment_interest);
amount_owed =(principal_amount  payment_principal);
//Display Results
cout << " " << (i+1) << setw(15) << setiosflags(ios::fixed) << setprecision(2) << monthly_payment << setw(9) << setiosflags(ios::fixed) << setprecision(2) << payment_interest << setw(18) << setiosflags(ios::fixed) << setprecision(2) << payment_principal << setw(26) << setiosflags(ios::fixed) << setprecision(2) << amount_owed << endl;
}
}while(i < (years*12));
return 0;
}[]
2 Replies  3376 Views  Last Post: 11 March 2009  05:06 PM
Replies To: Loan amortization
#2
Re: Loan amortization
Posted 11 March 2009  05:05 PM
What exactly do you want the program to do? Where are you subtracting the principal from? Could you gives us a brief rundown of how this loan amortization works?
Help us help you!
Help us help you!
#3
Re: Loan amortization
Posted 11 March 2009  05:06 PM
principal_payment = the_amount_to_subtract;
Page 1 of 1
