Code:
#include <stdio.h>
#include <math.h>
main() {
int mon;
double price, finance, rate , mpay, tpay, r;
printf("Enter the price of the house (in $):");
scanf("%.2f", &price);
if (price<0)
printf("Please enter positive price\n");
else {
printf("Enter the amount to be financed (in $):");
scanf("%.2f", &finance);
if ((finance<0)||(finance>0.8*price))
printf("Please enter appropriate values for finance\n");
else {
printf("Enter the annual percentage rate (in percent):");
scanf("%.2f", &rate);
if (rate<=0)
printf("Please enter a positive rate\n");
else {
r=(double)rate/1200;
printf("Enter the term in number of months:");
scanf("%d", &mon);
if ((mon<=0)||(mon%12!=0)||(mon>480))
printf("Please enter appropriate value for number of months\n");
else {
mpay=finance*r*pow((1+r),mon)/(pow((1+r),mon)-1);
tpay=mon*mpay;
printf("\nThe price of the house is: %.2f $\n", price);
printf("The amount to be financed is: %.2f $\n", finance);
printf("The annual percentage rate is: %.2f percent\n", rate);
printf("Your monthly payment is : %.2f $\n", mpay);
printf("Your total payment will be: %.2f $\n", tpay);
}
}}}}
When i run this code, it asks for the first price, and after that, it skips to the the message "Please enter correct rate". like it doesnt even go to the second scanning part where it asks for the finance. Please Help