Hi, I'm trying to make a program to calculate garage charges, and having a trouble with calculating overnight charges. When time entered between 4PM and 6AM and exit by 8AM a charge must be $11, but my program gives me wrong output. Please help, can't understand what mistake is.

Here is a function to calculate charges

Code:

int calculate_charge(int x)
{
if(((16<=hour_in)&&(hour_in<6))&&(hour_out<=8))
{
charge=11;
}
else
{
if(x>10&&x<=24)
charge=27;
else if(x>=0&&x<1)
charge=8;
else if(x<2)
charge=12;
else if(x<3)
charge=16;
else
charge=22;
}
//printf("\n%i",charge);
return charge;
}

And this the whole program.

Code:

#include<stdio.h>
int hour_in, min_in, hour_out, min_out;
int daytime, eveningtime, hour,total_hour;
int charge, amount_collected;
void get_time_in_and_out(void)
{
int AM_PM;
printf("Enter time in\n");//enter time in
printf("\tHour:");
scanf("%i",&hour_in);
printf("\n\tMinuts:");
scanf("%i",&min_in);
printf("\n0 - AM ; 1 - PM\t");
scanf("%i",&AM_PM);
if(AM_PM==1&&hour_in<12)
{
hour_in+=12;
}
else if(AM_PM==0&&hour_in==12)
{
hour_in+=12;
}
else
{
hour_in+=0;
}
printf("\nEnter time out\n");//enter time out
printf("\tHour:");
scanf("%i",&hour_out);
printf("\n\tMinuts:");
scanf("%i",&min_out);
printf("\n0 - AM ; 1 - PM\t");
scanf("%i",&AM_PM);
if(AM_PM==1&&hour_out<12)
hour_out+=12;
else if(AM_PM==0&&hour_out==12)
hour_out+=12;
else
hour_out+=0;
}
int calculate_hours(void)
{
int total;
total=(((hour_out*60)+min_out)-((hour_in*60)+min_in));
hour=total/60;
return hour;
}
int calculate_charge(int x)
{
if(((16<=hour_in)&&(hour_in<6))&&(hour_out<=8))
{
charge=11;
}
else
{
if(x>10&&x<=24)
charge=27;
else if(x>=0&&x<1)
charge=8;
else if(x<2)
charge=12;
else if(x<3)
charge=16;
else
charge=22;
}
//printf("\n%i",charge);
return charge;
}
void main(void)
{
int Done=1;
int car=1;
int amount_collected=0;
total_hour=0;
do
{
printf("Car#%i:\n\n", car);
get_time_in_and_out();
calculate_hours();
total_hour+=hour;
calculate_charge(hour);
amount_collected+=charge;
++car;
printf("===============================");
printf("\n1 -Next car\n0 -Done ");
scanf("%i",&Done);
printf("===============================\n\n");
}while(Done==1);
printf("Tota Hours Parked:\t %i\n",total_hour);
printf("Amount Collected:\t%i\n",amount_collected);
}