Guest User

Untitled

a guest
Oct 18th, 2017
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.72 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     const int numPaymentsPerYr = 12; //Prevent bugs, keep it simple.
  8.     double loanSize, decIntPerYear, interestRate, totalPayments, decIntPerPayment, factor;
  9.     int loanDuration;
  10.  
  11.     cout << "Please enter the size of the loan:";
  12.     cin >> loanSize;
  13.    
  14.     cout << "Please enter the loan's duration:";
  15.     cin >> loanDuration;
  16.  
  17.     totalPayments = numPaymentsPerYr * loanDuration;
  18.  
  19.     cout << "Please enter the interest rate:";
  20.     cin >> interestRate;
  21.  
  22.     decIntPerYear = interestRate / 100;
  23.     decIntPerPayment = interestRate / numPaymentsPerYr;
  24.  
  25.     factor = pow(1 - (decIntPerPayment),(-totalPayments)) / (decIntPerPayment);
  26.  
  27.     cout << loanSize / factor ;
  28.  
  29.     return 0;
  30. }
Add Comment
Please, Sign In to add comment