1. ## Programming Help

Hello,
I have to program a mortgage calculator based on the equal monthly payments formula. I have everything set except i keep getting 1.#INF as my value. I know this means infinity but can anyone tell me why?

thanks!
here is the code:

#include<stdio.h>
#include<conio.h>
#include<math.h>

main ()
{
double price_of_the_house, amount_financed, annual_rate, monthly_pay, total_pay, r;
int n;

printf("Enter the price of the house (in \$): ");
scanf("%lf", &price_of_the_house);
printf("Enter the amount to be financed (in \$): ");
scanf("%lf", &amount_financed);
printf("Enter the annual percentage rate (in %%): ");
scanf("%lf", &annual_rate);
printf("Enter the term in number of months: ");
scanf("%lf", &n);

r = annual_rate/12;
monthly_pay = amount_financed * r * pow(1+r,n)/(pow(1+r,n) - 1);
total_pay = monthly_pay * 12;

if ( price_of_the_house < 0 || amount_financed < 0 || annual_rate <= 0 || n < 0
|| amount_financed > 0.8 * price_of_the_house || n % 12 != 0 || n > 480 )
{
printf("One of the following errors have occurred:\n");
printf("1) Price of house, amount financed, annual rate or number of months is/are negative.\n");
printf("2) Annual rate or number of months is/are zero.\n");
printf("3) Amount financed is larger than 80%% of the price of the house.\n");
printf("4) The number of months is not a multiple of 12.\n");
printf("5) The number of months is greater than 480.\n");
}
else
{
printf("The price of the house is: %.2f \$\n", price_of_the_house);
printf("The amount to the financed is: %.2f \$\n", amount_financed);
printf("The annual percentage rate is: %.2f %%\n", annual_rate);
printf("Your monthly payment is: %f \$\n", monthly_pay);
printf("Your total payment will be: %f \$\n", total_pay);
}

getch(); return 0;
}

2. You're probably dividing by zero. This line looks like a prime candidate for said operation:

Code:
`monthly_pay = amount_financed * r * pow(1+r,n)/(pow(1+r,n) - 1);`

3. What's with the rash of posts without code tags!?

Just how big a font does "READ THIS FIRST" need to be in before people start reading it.

4. Originally Posted by Salem
What's with the rash of posts without code tags!?

Just how big a font does "READ THIS FIRST" need to be in before people start reading it.
I'll bet you that if you make it so big it takes up the entire screen, people that post without code tags will still scroll past it, irregardless of its size.

5. I wonder if the OP saw the popup which detects untagged code.

I further wonder whether they 'fixed' it by turning off JS rather than paying attention to the message.