ended up making a monthly remaining balance mortgage program. would be nnice if it worked tho. I was on a roll until I tried to add the feature of showing the remaining balance each month until the entire loan was paid off.
anyway, here's what I did... corrections appreciated
#include
#include
#include
//Program figures out a mortgage repayment schedule
//Showing the user how much of the balance on the loan remains after each month
using namespace std;
int main(int argc, char *argv[])
{
char exit;
double amount;
int term;
double rate;
double result;
double principal;
double monthly_interest;
double towards_bal;
double new_bal;
double new_interest_amount;
int count;
//To escape the program Hit x
cout << "To exit Hit x";
cin >> exit;
cout << endl;
//Program runs unless x is hit
while (exit != 'x');
{
//User enters Amount without commas
cout << "Enter full amount of your home mortgage loan: $";
cin >> amount;
cout << "Enter the interest rate in percentage: %";
cin >> rate;
cout << "How much can you pay per month in dollars: $";
cin >> principal;
monthly_interest = (rate / 12) * amount * 0.01;
cout << "Your monthly interest is: $" << monthly_interest << endl;
towards_bal = principal - monthly_interest;
cout << "Contribution towards balance of principle would be: $" << towards_bal;
cout << endl;
cout << endl;
new_bal = amount - towards_bal;
//After the first month is figured out, a do while loop is entered in order
//to display the remaining balances for each month until the entire loan
//is pay off, in other words until the balance equals zero
do
{
outData.open("a:\\prog.out"); //open output file
outData << endl;
outData << "Balance: $" << new_bal << endl;
cout << endl;
cout << "Your new balance as of the following month would be: $";
cout << new_bal;
cout << endl;
new_interest_amount = monthly_interest = (rate / 12) * new_bal * 0.01;
cout << "Based on this payment next month's interest amount would be: $";
cout << new_interest_amount;
cout << endl;
towards_bal = principal - new_interest_amount;
cout << "Contribution towards balance of principle would be: $" << towards_bal;
new_bal = new_bal - towards_bal;
}
while (new_bal != 0);
cout << endl;
}
outData.close();
}
system("PAUSE");
return EXIT_SUCCESS;
}