Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Program Name: monthlypayments.cpp
- //Programmer: John Burns
- //Purpose: To display monthly payments of a mortgage
- //Program Date: Ocotber 6th 2008
- #include<iostream>
- #include<iomanip>
- #include<cmath>
- using namespace std;
- void main()
- {
- //variables
- double rateAnnual, rateMonthly;
- int numPayment;
- double loanAmount, payment, totalAmount, interestPaid;
- //inputs
- cout << "What is the percentage rate?: ";
- cin >> rateAnnual;
- cout << "How many payments?: ";
- cin >> numPayment;
- cout << "What is the loan amount?: $";
- cin >> loanAmount;
- //calculations
- rateMonthly = (rateAnnual * .01)/12;
- payment = ((rateMonthly * pow(1+rateMonthly,numPayment))/(pow(1+rateMonthly,numPayment)-1))*loanAmount;
- totalAmount=payment*numPayment;
- interestPaid=totalAmount-loanAmount;
- //Outputs
- cout << setprecision(2) << fixed << right << showpoint;
- cout << endl;
- cout << "Loan amout: $" << setw(9) << loanAmount << endl;
- cout << "Monthly Interest Rate: " << setw(9) << rateMonthly * 100 << "%" << endl;
- cout << "Number of Payments: " << setw(9) << numPayment << endl;
- cout << "Monthly Payments: $" << setw(9) << payment << endl;
- cout << "Amount Paid Back: $" << setw(9) << totalAmount << endl;
- cout << "Interest Paid: $" << setw(9) << interestPaid << endl;
- }
Add Comment
Please, Sign In to add comment