Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // A practice program to calculate a (theoretical) loan payment scheme
- #include <iostream>
- #include <cmath>
- using namespace std;
- int main ()
- {
- double Principal, IntRate, PayPerYear, NumYears, Payment, numer, denom, b , e, TotalInterest = 0.0;
- double runningtotal, monthcount;
- cout << "What is the principal?\n";
- cin >> Principal;
- cout << "What is the interest rate?\n";
- cin >> IntRate;
- cout << "How many payments per year?\n";
- cin >> PayPerYear;
- cout << "How many years of payment?\n";
- cin >> NumYears;
- numer = IntRate*(Principal/PayPerYear);
- e = -(PayPerYear * NumYears);
- b = (IntRate/PayPerYear)+1;
- denom = 1 - pow(b, e);
- Payment = numer / denom;
- cout << "Payment is " << Payment;
- runningtotal = Principal;
- for(monthcount = (NumYears*12); monthcount >= 0; --monthcount) {
- TotalInterest += (IntRate * runningtotal);
- cout << "\n" << TotalInterest;
- runningtotal -= Payment;
- }
- cout << "\nPayment is " << Payment << "\n Total interest payed is " << TotalInterest << "\n";
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement