Guest User

Untitled

a guest
May 24th, 2018
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. //Program Name: monthlypayments.cpp
  2. //Programmer: John Burns
  3. //Purpose: To display monthly payments of a mortgage
  4. //Program Date: Ocotber 6th 2008
  5.  
  6. #include<iostream>
  7. #include<iomanip>
  8. #include<cmath>
  9. using namespace std;
  10.  
  11. void main()
  12. {
  13. //variables
  14. double rateAnnual, rateMonthly;
  15. int numPayment;
  16. double loanAmount, payment, totalAmount, interestPaid;
  17.  
  18. //inputs
  19. cout << "What is the percentage rate?: ";
  20. cin >> rateAnnual;
  21. cout << "How many payments?: ";
  22. cin >> numPayment;
  23. cout << "What is the loan amount?: $";
  24. cin >> loanAmount;
  25.  
  26. //calculations
  27. rateMonthly = (rateAnnual * .01)/12;
  28. payment = ((rateMonthly * pow(1+rateMonthly,numPayment))/(pow(1+rateMonthly,numPayment)-1))*loanAmount;
  29. totalAmount=payment*numPayment;
  30. interestPaid=totalAmount-loanAmount;
  31.  
  32. //Outputs
  33. cout << setprecision(2) << fixed << right << showpoint;
  34. cout << endl;
  35. cout << "Loan amout: $" << setw(9) << loanAmount << endl;
  36. cout << "Monthly Interest Rate: " << setw(9) << rateMonthly * 100 << "%" << endl;
  37. cout << "Number of Payments: " << setw(9) << numPayment << endl;
  38. cout << "Monthly Payments: $" << setw(9) << payment << endl;
  39. cout << "Amount Paid Back: $" << setw(9) << totalAmount << endl;
  40. cout << "Interest Paid: $" << setw(9) << interestPaid << endl;
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47. }
Add Comment
Please, Sign In to add comment