This is a two part question: 1st, How do I use a negative value in an equation? I tried just putting a "-" in front of the number, but my calculations are not coming out correctly. 2nd, My error could be related to "pow"... I am using an equation for each argument, and I'm wondering if that might be what is throwing the whole thing off... Any help would be greatly appreciated!!! Thank you!! :)
okay, here's the code:
Code:{
float L; //amount of loan
float R; //annual interest rate
float r = (R * 0.01) / 12; //monthly interest rate
int i; //length of loan in years
double P = L * (r / 1 - pow( (1 + r), (-i * 12) ) ); //monthly payment
double total = P * (i * 12); //total amount paid to bank
cout << setw(7);
cout << setiosflags(ios::fixed | ios::showpoint);
cout << setprecision(2);
cout << "\nEnter the loan amount: ";
cin >> L;
cout << "\nEnter the annual interest rate: ";
cin >> R;
cout << "\nEnter the length of the loan in years: ";
cin >> i;
cout << "\n\nLoan: $" << L << endl;
cout << "Interest-rate: " << R << " %\n";
cout << "Years: " << i << endl;
cout << "Monthly Payment: $" << P << endl;
cout << "\nTotal-paid: $" << total << endl;
}