
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)^(kn)]/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.
If you're still reading this ..here is the source code I've gotten so far... Please Help :(
#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)),NK))/(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

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)^(kn)]/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

Thanks
Hey thanks a lot bro..I appreciate it big time!