Pricing at the hourly rate only until this exceeds the daily rate

52 Views Asked by At

Pricing at the hourly rate only until this exceeds the daily rate

Example: if a rent costs \$1 per hour, \$10 per day and a booking for 11 hours will be charged \$10. For two complete days it will charge as \$20. For 2 complete days and 2 hr the price will be \$22. The same principle goes for weekly and monthly bookings. Is there any equation in general for this problem ?

1

There are 1 best solutions below

0
On

To clarify the problem, I will assume that:

1) rental for part of an hour is charged for a full hour,

2) a "full day" is $24$ hours,

3) rental is for a continuous interval of time,

4) rental for each full day is $\$10$,

5) rental for hours after the full days is $\$1$ per hour, with a maximum charge of $\$10$.

My formula uses these functions:

1) $\lceil x\rceil$ is the ceiling function: $x$ rounded up to the smallest integer that is greater than or equal to $x$.

2) $\lfloor x\rfloor$ is the floor function: $x$ rounded down to the greatest integer that is less than or equal to $x$.

3) $x \bmod y$ is the remainder of $x$ when divided by $y$.

4) $\min(x,y)$ is the minimum function: the lesser of $x$ and $y$.

Then the formula for the rental for $h$ hours is

$$10\left \lfloor\frac{h}{24} \right \rfloor +\min \left(\lceil h \bmod 24 \rceil ,10\right)$$

This formula could be done with fewer special functions, but that would make the formula longer and more difficult looking.