So our problem goes like this:
* A parking lot charges 50 units for the first 3 hours.
* 10 units will be charged for every additional hour.
* A fraction of an hour (e.g. 30 minutes) is still considered an hour and will be charged as such.
Here is the program I have so far to compute the parking fee:
I cannot get ceil() to work. When I enter 10.5 hours for example, it returns 125 when it should be 130.
// Function of parking fee
int main (void)
float hrs, fee, temp;
printf ("Enter no. of hours: ");
scanf (" %f", &hrs);
if (hrs <= 0)
printf ("Your input is invalid!\n\n");
while (hrs <= 0);
if (hrs >= 3)
fee = (10 * hrs) + 20;
temp = ceil (fee);
printf ("Your parking fee is: %.2f", temp);
fee = 50;
printf ("Your parking fee is: %.2f", fee);