2 Replies - 1971 Views - Last Post: 11 March 2009 - 05:06 PM Rate Topic: -----

#1 mortgagelady7  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 11
  • Joined: 28-February 09

Loan amortization

Posted 11 March 2009 - 03:35 PM

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) << " Payment-Interest " << setw(12) << " Payment-Principal " << 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;
}[]

Is This A Good Question/Topic? 0
  • +

Replies To: Loan amortization

#2 crazyjugglerdrummer  Icon User is offline

  • GAME OVER. NERD WINS.
  • member icon

Reputation: 119
  • View blog
  • Posts: 690
  • Joined: 07-January 09

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! :)
Was This Post Helpful? 0
  • +
  • -

#3 sparkart  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 113
  • View blog
  • Posts: 688
  • Joined: 16-February 09

Re: Loan amortization

Posted 11 March 2009 - 05:06 PM

principal_payment -= the_amount_to_subtract;

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1