#include<stdio.h>
double taxifee(double hours,double distance);
int main()
{
printf("enter hours and distance\n");
int hours,distance;
double totalprice;
scanf("%lf %lf",&hours,&distance);
taxifee(hours,distance);
printf("the fee is %lf",totalprice);
return 0;
}
double taxifee(double hours,double distance)
{
double totalprice=0.0;
double perprice=2.3;
double startprice=13.0;
if(hours<0||hours>24)
{
printf("enter a correct number~~");
return 0;
}
else if (hours<5&&hours>=23)
{
perprice*=1.2;
}
if(distance<=3)
{
totalprice=startprice;
}
else
{
totalprice=startprice+(distance-3)*perprice;
}
totalprice++;
return totalprice;
}
#include<stdio.h>
double taxifee(double hours,double distance);
int main()
{
printf("enter hours and distance\n");
int hours,distance;
double totalprice;
scanf("%lf %lf",&hours,&distance);
taxifee(hours,distance);
printf("the fee is %lf",totalprice);
return 0;
}
double taxifee(double hours,double distance)
{
double totalprice=0.0;
double perprice=2.3;
double startprice=13.0;
if(hours<0||hours>24)
{
printf("enter a correct number~~\n");
return 0;
}
else if (hours>=5 && hours<23)
{
perprice = perprice;
}else
{
perprice *= 1.2;
}
if(distance<=3)
{
totalprice=startprice;
}
else
{
totalprice=startprice+(distance-3)*perprice;
}
totalprice++;
return totalprice;
}
else if (hours<5&&hours>=23)这句中的&&应该改为||