Share Pastebin
Guest
Public paste!

Graeme

By: a guest | Feb 9th, 2010 | Syntax: C++ | Size: 1.12 KB | Hits: 12 | Expires: Never
Copy text to clipboard
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5.     int months;
  6.     double cost, interest, payment, leftover, total_interest, rate;
  7.  
  8.  
  9.     total_interest = 0;
  10.     months = 0;
  11.  
  12.     cout << "How much credit is being advanced: ";
  13.     cin >> cost;
  14.     cout << "What is the annual interest rate in percentage: ";
  15.     cin >> rate;
  16.     rate = rate/1200;
  17.     cout << "What is the monthly repayment amount: ";
  18.     cin >> payment;
  19.     cout << "\n\n\n";
  20.  
  21.     while (cost > 0)
  22.            {interest = cost*rate;
  23.             leftover = payment-interest;
  24.             cost = cost-leftover;
  25.             total_interest = total_interest + interest;
  26.  
  27.             months = months + 1;
  28.  
  29.             cout << "Month: " << months << endl;
  30.             cout << "Remaining Balance: " << cost << endl;
  31.             cout << "Monthly Interest: " << interest << endl;
  32.             cout << "Total Interest so far: " << total_interest << endl << endl;
  33.  
  34.  
  35.            }
  36.  
  37.     cout << "Number of months taken to pay: " << months << endl;
  38.     cout << "Total interest paid: " << total_interest << endl;
  39.  
  40.  
  41.  
  42.     system("PAUSE");
  43.         return 0;
  44. }