{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

copied houspayment

# copied houspayment - payment = calc(pay ir mir year payment...

This preview shows pages 1–4. Sign up to view the full content.

/* Kelvin Freitas Programming I Due Sep, 26, 2011 Program Name: House Payment Program This program will take user input for a principal value, interest rate and an ammount of years, calculating then the monthly payment for a mortgage.*/ #include <iostream> #include <math.h> #include <iomanip> using namespace std; double calc (double pay, double ir, double mir, double year, double payment){ double a = 0; double b = 0; double c = 0; double d = 0; double e = 0; double f = 0; mir = ir/1200; a = 1+mir; b = 1/a; c = 12*year; d = pow(b,c); e = 1-d; f = pay*mir;

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
payment = f/e; return payment; } int main (){ double pay = 0; double mir = 0; double year = 0; double ir = 0; double payment = 0; double tp = 0; double rb = 0; double tpp = 0; double pp = 0; double mint = 0; cout << "This program will calculate the monthly payment for a long term loan." << endl; cout << "Enter the Principal payment." << endl; cin >> pay; cout << "Enter Monthly Interrest Rate." << endl; cin >> ir; cout << "Enter Number of Years." << endl; cin >> year;

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: payment = calc(pay, ir, mir, year, payment); printf("Principal: %.2f Interest Rate: %.2f Years: %.2f payment: %.2f \n", pay, ir, year, payment); cout << " " << endl; cout << " Month Pay Total Monthly Principal Total Remaining " << endl; cout << " Paid Interest Paid Principal Balance " << endl; cout << " Paid " << endl; cout << " " << endl; rb = pay; for(int i=1; i<=360; i++){ if(i==1){ mint = (ir/1200)*pay; } else{ mint = (ir/1200)*rb; } pp = (payment-mint); rb = (rb-pp); tp += payment; tpp += pp; if(i<=8 || i>=353){ cout << setw(10) << setprecision(2) << fixed << i; cout << setw(10) << setprecision(2) << fixed << payment; cout << setw(10) << setprecision(2) << fixed << tp; cout << setw(10) << setprecision(2) << fixed << mint; cout << setw(10) << setprecision(2) << fixed << pp; cout << setw(10) << setprecision(2) << fixed << tpp; cout << setw(10) << setprecision(2) << fixed << rb << endl; } if(i==9){ cout << " - - - - - - - \n";...
View Full Document

{[ snackBarMessage ]}

### Page1 / 4

copied houspayment - payment = calc(pay ir mir year payment...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online