To view the text of the problem, visit the class yahoo groups site.
#include <iostream>
using namespace std;
int main()
{
cout << "-- TOTAL INTEREST --" << endl << endl;
float price, annualRate, monthlyRate, payment;
const int MONTHS_IN_YR = 12;
cout << "Price : ";
cin >> price;
cout << "Annual Interest Rate (%) : ";
cin >> annualRate;
cout << "Monthly Payment : ";
cin >> payment;
monthlyRate = annualRate / MONTHS_IN_YR;
float interest = 0, totalInterest = 0;
float balance = price;
int months = 0;
while (balance > 0)
{
interest = balance * monthlyRate / 100;
balance -= (payment-interest);
months++;
totalInterest += interest;
}
cout << "Total Interest paid : " << totalInterest << endl;
cout << "Months until paid up : " << months << endl;
system("PAUSE");
return 0;
}