@Matticus, thanks for the input, and I actually only got one "unused variable" warning originally. I've gotten a little more into it and am having issues with the payment calculation now. It's coming back with payments that are way too low (not even half what they should be). I'm also getting a different warning now about "call to 'pow' with no prototype in main". Any chance someone can point out where I'm dropping the ball on this?
Here's the newest code:
Code:
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
int main()
{
double moPay, annRate, principal, rate, ratePow, totalPmt, totalInt;
int months, yrs, term;
/* - moPay is the monthly paymount amount to be calculated
- annRate is the annual interest rate
- principal is the loan amount before interest
- yrs is the number of years the loan is for
- term is the life of the loan converted into months by multiplying yrs by 12
*/
/* user input of loan data */
printf("\nEnter the amount of the loan: ");
scanf("%lf", &principal);
printf("\nNow enter the life of the loan in years: ");
scanf("%d", &yrs);
printf("\nEnter the annual interest rate for the loan (example: 5%% is 5): ");
scanf("%lf", &annRate);
/* loan and payment calculation */
term=yrs * 12;
rate=annRate / 1200.0;
moPay=(rate+rate / (pow (1.0+rate, term)-1.0)) * principal;
totalPmt=term * moPay;
totalInt=totalPmt - principal;
/* output loan and payment details */
printf("\nPrincipal is %.2lf, term is %d months, and rate is %.0lf%%.\n", principal,term,annRate);
printf("\nYour monthly payment is %.2lf.\n\nYour total interest is %.2lf.\n\nYour total payment is %.2lf.\n", moPay,totalInt,totalPmt);
system("pause");
return 0;
}