Click here to Skip to main content
15,886,422 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
Hey =) I'm doing some studying pre-exams, and i have this excercise where they want me to create a program that will give the user "Flight time" when he inserts where he wants to travel from, destination, and which speed he wants to fly in. Also they added a list of destinations, and 2 startng places , showing distance from the 2 startng places to all destinations. Any idead how i should do this?
All help would be much apreciated =)
Thank you !
Posted
Updated 20-May-13 8:22am
v2
Comments
Richard C Bishop 20-May-13 14:23pm    
I have several. What is your idea? This is a very simple task. Take each step one by one and think about what you need in order to complete it.
Twinniez 20-May-13 15:27pm    
I rly just wonder what method to use... :P Im quite the noob, so if you by any chance could like point me in the right direction :P

1 solution

Time = Distance/Speed

If you only have lat/long of the locations, look up Great Circle Formula to get the formula on how to calculate the distance between two points on the globe. Then for each starting place, calculate the distance to every other place in your list.

BTW, its important to note about the Distance/Speed formula, that the denominator needs to be in the same units as the numerator. For example, 100km/50mph != 2h, even though thats the answer you will get. Make sure that if your numerator is in kilometers, the the denominator is in kph, if numerator is in miles, denominator must be mph.
 
Share this answer
 
v2
Comments
Twinniez 20-May-13 15:18pm    
hmm :) thanks alot! But im aware of how to do the math, the programming is what stops me :) I'm quite the noob when it comes to this, so what my real question is (though quite poorly pointed out) what method/how to program it :P
Ron Beyer 20-May-13 15:34pm    
There are tons of references, all you have to do is search, like this one:
http://www.codeproject.com/Articles/12269/Distance-between-locations-using-latitude-and-long
Then using the number you get from that, divide by the entered speed, and voila! Time!
Twinniez 20-May-13 15:35pm    
Thanks! :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900