I am trying to run balN
with the variable N
changing as I change it in the program but balN
is only running it with the value that was assigned with N
at the very beginning. How can I make it so balN
will change as the value of N
changes? I am new to programming so any help will be appreciated. Thanks!
const double Monintrate = 0.09 / 12.0;
const double Totnum = 36.0;
const double Payment = 165.25;
int main ()
{
double N = 1.0;
double balN = Payment * (1 - pow(1 + Monintrate, N - Totnum))/Monintrate;
cout << fixed;
cout << setprecision(2) << "Monthly Payment: $" << Payment << endl;
cout << "Annual Interest rate: 9%" << endl;
cout << "Total Number of Payments: " << Totnum << endl << endl;
cout << "Balance after Payment:" << endl;
cout << "1: $" << balN << endl;
N++;
cout << "2: $" << balN << endl;
N++;
cout << "3: $" << balN << endl;
}