Hello all,
I am working on a program which calculates loan information. For some reason the program keeps looping even though I have set the loop variables to stop when month count gets to 60 or the balance is a 0 or less than. Looking for some hints.
Thanks
Code:
#include <iostream>
#include <iomanip>
using namespace std;
double loanbalance;
double interestrate;
double payment;
double newloanamt;
int monthnum= 0;
int i=1;
float fBalance;
int main ()
{
cout << "Starting loan balance: $";
cin >> loanbalance;
cout << "Annual interest rate: %";
cin >> interestrate;
cout << "Monthly payment: $";
cin >> payment;
cout << " \nMonth\tBalance" << endl;
while (monthnum < 60 || loanbalance<=0){
monthnum = monthnum + 1;
loanbalance = loanbalance*(interestrate/12) + loanbalance - payment;
cout << monthnum << "\t" << loanbalance << endl;
}
return 0;
}