Jump to content


Corporate Sponsors


Latest News: (loading..)

- - - - -

Google Maps route calculations


1 reply to this topic

#1 madison

  • Community Member
  • 1 posts
  • Real Name:Matt

Posted 16 December 2011, 13:13

Hi,

Not sure if anyone out there can assist. I am trying to create a taxi fare calculator using google maps to calculate the route between two points, the mileage and then the price. So far (and with help) I have been able to get it working but I am struggling with the various options that need to be accounted for when calculating a fare.

I need to use several if else statements so that if a customer wants a price for 3 people at 10am they are given the standard taxi day rate but, if they want to have 5 people in the day it uses a 'bus rate'. Similarly, both rates are then subject to a night time tariff!

So, my question is, is it possible to use this many variables using the if else statement or do I need to find another way of doing it.

Thanks.

#2 germ

  • Community Member
  • 13,587 posts
  • Real Name:Jim
  • Gender:Male
  • Location:USA (GMT-6)

Posted 16 December 2011, 21:50

If you have more than 2 possibilities a "switch" usually works better (IMHO).

The ever popular "if ... else..." works great for dealing with two possible situations. If you have much more than that it leaves a lot to be desired.
If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you.

"Headers already sent" - The definitive help

"Cannot redeclare ..." - How to find/fix it

SSL Implementation Help

Like this post? "Like" it again over there >