# Loan amortization

Page 1 of 1

## 2 Replies - 3804 Views - Last Post: 11 March 2009 - 05:06 PMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=92161&amp;s=52d001e65984b436e9e9c2e71983c1ef&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

Reputation: 0
• 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

• GAME OVER. NERD WINS.

Reputation: 122
• 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?

### #3 sparkart

Reputation: 115
• Posts: 696
• Joined: 16-February 09

## Re: Loan amortization

Posted 11 March 2009 - 05:06 PM

```principal_payment -= the_amount_to_subtract;
```

Page 1 of 1

 .related ul{list-style-type:circle;font-size:12px;font-weight:bold;}.related li{margin-bottom:5px;background-position:left 7px!important;margin-left:-35px;}.related h2{font-size:18px;font-weight:bold;}.related a{color:blue;}