# Problems

• 02-27-2002
ProgrammingDlux
Problems
Hey guys, if anyone can help I'd greatly appreciate it. I have this homework problem that doesn't seem to wanna work with me.
"you have bought a car, taking out a loan with annual interest rate of 9%. You will make 36 monthly payments of \$165.25 each. You want to keep track of the remaining balance you owe after each monthly payment. The formula for the remaining balance is:

Bal k= pmt[1-(1+i)^(k-n)]/i

Bal k = balance remaining after kth payment
k= payment number (1,2,3...)
pmt= amount of monthly payment
i= interest rate per month (annual rate /12)
n= total number of payments to be made.

#include<iomanip.h>
#include<math.h>

main()
{ _asm finit;
int K, N;
float Pmt=165.25, I=.09, Bal;

for (N=1;N<=36;N++){
cout<<"\nPayment Number: "<<N<<endl;

Bal = Pmt* (1- pow((1+(I/12)),N-K))/(I/12);

cout.setf(ios::floatfield, ios::showpoint);
cout.setf(ios::fixed) ;
cout<<setprecision(2) ;

cout<<"Monthly Payment is: \$" <<Pmt<<endl; cout<<"Monthly Interest Rate is: " <<I<<endl ;
cout<<"Total Number of Payments is: "<<N<<endl ;
cout<<"Balance is : \$" <<Bal<<endl;

}//for loop

return 0;
}//main
• 02-27-2002
biosx
Here, I fixed up your code.

Mainly, you had the variables N and K doing each other's job. So I just switched those and did some other housekeeping. I believe that this is what you wanted:
Code:

```#include<iomanip.h> #include<math.h> main() {   _asm finit;           int K,  N = 36;   double Pmt = 165.25, I=0.09, Bal;   for (K = 1; K <= 36; K++)   {     cout << endl <<"Payment Number: "<< K << endl;     Bal = Pmt * ( 1 - pow((1 + I/12),(K - N)) ) / (I/12);  //Bal k= pmt[1-(1+i)^(k-n)]/i      cout.setf(ios::floatfield, ios::showpoint);     cout.setf(ios::fixed) ;                     cout << setprecision(2)         << "Monthly Payment is: \$" << Pmt <<endl         << "Monthly Interest Rate is: " << I/12 <<endl         << "Total Number of Payments is: "<< N <<endl          << "Balance is: \$" << Bal <<endl;   } return 0; }```
Good luck
• 02-27-2002
ProgrammingDlux
Thanks
Hey thanks a lot bro..I appreciate it big time!