Win a copy of The Business Blockchain this week in the Cloud forum!

Help with IF statements

ahmedali ali
Greenhorn
Posts: 1
Hi guys, im in need of some help with my project, so any help would be greatly appreciated.

My app is to be able to find out the cost of a journey between two stations. The cost of the journey depends on which zones the station is located in.

So far i have two spinners which have a list of stations :-

Station A = Zone 2
Station B = Zone 3
Station C = Zone 3
Station D = Zone 1
Station E = Zone 2 etc...

The only method i could think of is very long and tiring, which is to do an if statement for each possible journey e.g if "spinner1 = station A" and "spinner 2 = Station B" then "cost = 25"

I was hoping to find a quicker method based on the zones, for example all the journeys from Zone 1 to Zone 2 = "Cost=20"

any examples or pointers in the right direction would be great

Misha van Tol
Ranch Hand
Posts: 56
Depends on how the price is calculated, and how the stations are placed in the zone map. If the price between all zone's is equal and all stations are sequentially placed on one line traveling from zone 1 to zone 2 and so on, you can calculate how many zone's you travel trough (end zone minus starting zone) and multiply that with the cost per zone.

If that's not the case you can create a two dimensional array containing the prices and use something like: