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

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

View Full Document Right Arrow Icon
/* 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;
Background image of page 1

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

View Full DocumentRight Arrow Icon
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;
Background image of page 2
Background image of page 3

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

View Full DocumentRight Arrow Icon
Background image of page 4
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(&quot;Principal: %.2f Interest Rate: %.2f Years: %.2f payment: %.2f \n&quot;, pay, ir, year, payment); cout &lt;&lt; &quot; &quot; &lt;&lt; endl; cout &lt;&lt; &quot; Month Pay Total Monthly Principal Total Remaining &quot; &lt;&lt; endl; cout &lt;&lt; &quot; Paid Interest Paid Principal Balance &quot; &lt;&lt; endl; cout &lt;&lt; &quot; Paid &quot; &lt;&lt; endl; cout &lt;&lt; &quot; &quot; &lt;&lt; endl; rb = pay; for(int i=1; i&lt;=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&lt;=8 || i&gt;=353){ cout &lt;&lt; setw(10) &lt;&lt; setprecision(2) &lt;&lt; fixed &lt;&lt; i; cout &lt;&lt; setw(10) &lt;&lt; setprecision(2) &lt;&lt; fixed &lt;&lt; payment; cout &lt;&lt; setw(10) &lt;&lt; setprecision(2) &lt;&lt; fixed &lt;&lt; tp; cout &lt;&lt; setw(10) &lt;&lt; setprecision(2) &lt;&lt; fixed &lt;&lt; mint; cout &lt;&lt; setw(10) &lt;&lt; setprecision(2) &lt;&lt; fixed &lt;&lt; pp; cout &lt;&lt; setw(10) &lt;&lt; setprecision(2) &lt;&lt; fixed &lt;&lt; tpp; cout &lt;&lt; setw(10) &lt;&lt; setprecision(2) &lt;&lt; fixed &lt;&lt; rb &lt;&lt; endl; } if(i==9){ cout &lt;&lt; &quot; - - - - - - - \n&quot;;...
View Full Document

This note was uploaded on 01/30/2012 for the course ENG 1113 taught by Professor Irwin during the Fall '11 term at University of Central Oklahoma.

Page1 / 4

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

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

View Full Document Right Arrow Icon
Ask a homework question - tutors are online