nerateMonth(yy+1);
////sum next year day
//while (idx < em)
//{
// sumday = sumday+cnt[idx];
// idx++;
//}
return sumday;
}
//statistics how many days in complete month
int StatisticsMonthDays(int yy,int mm,int dd,int hh,int mi,int ey,int em,int idx)
{
int sumday = 0;
int *cnt ;
cnt =GenerateMonth(yy);
//statistics current month
if(idx == 0 && dd==0 && hh==0 && mi==0)
{
//complete month
sumday = sumday+cnt[mm];
}
else if( mm < em)
{
sumday = sumday+cnt[mm];
}
else if(ey>yy)
{
sumday = sumday+cnt[mm];
}
idx++;
return sumday;
}
//Statistics all Hour of day
double StatisticsHourOfDay(int car_type,int sumday)
{
double result = 0;
if(car_type == 1)
{
//small car
result = 60/Per_time * Smallcar_att * 14 * sumday;
}
else
{
result = 60/Per_time * Bigcar_att * 14 * sumday;
}
return result;
}
// Statistics all Hour of night
double StatisticsHourOfNight(int car_type,int sumday)
{
double result = 0;
if(car_type ==1)
{
result = Smallcar_night * 10 * sumday;
}
else
{
result = Bigcar_night * 10* sumday;
}
return result;
}
//Statistics per hour * sumhour of day
double StatisticsHourDayCost(int car_type,int sumhour,double pay)
{
double result = 0;
if(car_type == 1)
{
//small car
result = 60/Per_time * pay * sumhour;
}
else
{
result = 60/Per_time * pay * sumhour;
}
return result;
}
//
double StatisticsHourNightCost(int car_type,int sumhour)
{
double result = 0;
if(car_type == 1)
{
//small car
result = Smallcar_night * sumhour;
}
else
{
result = Bigcar_night * sumhour;
}
return result;
}
int StatisticsHour()
{
int sumhour = 0;
return ++sumhour;
}
//Statistic Cost of Parking car
int StatisticsCost(int sumday,int sumhour_night,int sumhour_day,int summinute,int car_type)
{
double cost = 0;
if (sumday > 0)
{
cost = cost + StatisticsHourOfDay(car_type,sumday);
cost = cost + StatisticsHourOfNight(car_type,sumday);
}
if(sumhour_day > 1 || sumhour_day >=1 && summinute > 0 )
{
if(car_type ==1 )
{
cost = cost +StatisticsHourDayCost(car_type,sumhour_day,Smallcar_att);
}
else
{
cost = cost +StatisticsHourDayCost(car_type,sumhour_day,Bigcar_att);
}
}
else if( sumhour_day == 1 && summinute == 0 || sumhour_day<=1 && summinute>0)
{
if(car_type ==1 )
{
cost = cost +StatisticsHourDayCost(car_type,sumhour_day,Smallcar_rule);
}
else
{
cost = cost +StatisticsHourDayCost(car_type,sumhour_day,Bigcar_rule);
}
}
if(sumhour_night > 0)
{
cost = cost + StatisticsHourNightCost(car_type,sumhour_night);
}
if(cost >0 )
{
//pass N hour
if(car_type ==1)
{
cost = cost + summinute * Smallcar_att;
}
else
{
cost = cost + summinute * Bigcar_att;
}
}
else
{
//first hour
if(car_type ==1)
{
cost = cost + summinute * Smallcar_rule;
}
else
{
cost = cost + summinute * Bigcar_rule;
}
}
printf("The car total Cost of parking car is %f",cost);
return 0;
}
//Statistic Time of parking car
int StatisticsTime(int sy,int sm,int sd,int sh,int smi,int ey,int em,int ed,int eh,int emi,int car_type)
{
int sumday = 0;
int sumhour_day = 0;
int sumhour_night = 0;
int summinute=0;
int idx = 0;
while (ey> sy || em> sm || ed> sd ||eh > sh|| emi > smi)
{
if(sy>ey)
{
break;
}
if((ey-sy>=2)||(ey>sy && em> sm) || (ey>sy && em>= sm && ed>sd) ||(ey>sy && em>= sm && ed>=sd && eh>sh)||(ey>sy && em>= sm && ed>=sd && eh>=sh && emi>=smi))
{
//start year less than end year indicate to park a year
sumday = sumday + StatisticsYearDays(sy,sm,sd,ed);
sy++;
}
else if(CheckMonth(sy,sm,sd,sh,smi,ey,em,ed,eh