Graeme
By: a guest | Feb 9th, 2010 | Syntax:
C++ | Size: 1.12 KB | Hits: 12 | Expires: Never
#include <iostream>
using namespace std;
int main() {
int months;
double cost, interest, payment, leftover, total_interest, rate;
total_interest = 0;
months = 0;
cout << "How much credit is being advanced: ";
cin >> cost;
cout << "What is the annual interest rate in percentage: ";
cin >> rate;
rate = rate/1200;
cout << "What is the monthly repayment amount: ";
cin >> payment;
cout << "\n\n\n";
while (cost > 0)
{interest = cost*rate;
leftover = payment-interest;
cost = cost-leftover;
total_interest = total_interest + interest;
months = months + 1;
cout << "Month: " << months << endl;
cout << "Remaining Balance: " << cost << endl;
cout << "Monthly Interest: " << interest << endl;
cout << "Total Interest so far: " << total_interest << endl << endl;
}
cout << "Number of months taken to pay: " << months << endl;
cout << "Total interest paid: " << total_interest << endl;
system("PAUSE");
return 0;
}