Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- using namespace std;
- int main()
- {
- const int numPaymentsPerYr = 12; //Prevent bugs, keep it simple.
- double loanSize, decIntPerYear, interestRate, totalPayments, decIntPerPayment, factor;
- int loanDuration;
- cout << "Please enter the size of the loan:";
- cin >> loanSize;
- cout << "Please enter the loan's duration:";
- cin >> loanDuration;
- totalPayments = numPaymentsPerYr * loanDuration;
- cout << "Please enter the interest rate:";
- cin >> interestRate;
- decIntPerYear = interestRate / 100;
- decIntPerPayment = interestRate / numPaymentsPerYr;
- factor = pow(1 - (decIntPerPayment),(-totalPayments)) / (decIntPerPayment);
- cout << loanSize / factor ;
- return 0;
- }
Add Comment
Please, Sign In to add comment