I am developing a management system reservations for a vehicle parking lot. I need an algorithm in javascript (if possible) that presents the estimate with the best cost-benefit. I considered the following hypothetical situations as examples. From N options, a combination of them with the best cost/benefit can be chosen.
- Client Staying for 30 Days:
- Option A: 31 days for $2200 (ratio: $2200/31 days = $70.96/min)
- Option B: 10 days for $800 (ratio: $800/10 days = $80/min)
- The best option is Option A because it offers an extra day and costs $200 less.
- Client Staying for 30 Days (Alternate Scenario):
- Option A: 39 days for $2860 (ratio: $2860/39 days = $73.33/min)
- Option B: 10 days for $800 (ratio: $800/10 days = $80/min)
- In this scenario, Option A has a better ratio, but the days are too long for the time spent, and the total cost is higher. Therefore, Option B is more favorable.
- Client Staying for 5 Days:
- Option A: 1 day for $1
- Option B: 2 days for $1.9
- Option C: 3 days for $4
- Combining Options A and B would be the best choice:
Total cost: $1 + $1.9 + $1.9 = $4.8
Total time: 1 day + 2 days + 2 days = 5 days