How can I calculate which runway to use for landing, based on the wind?
The name of a runway is a number indicating its direction in tens of degrees.1 For example, to land west-to-east, use runway 09. 

Generally, each runway paving may be used in either direction, and the physical paving actually contains two logical runways, running in opposite directions. Only one of these logical runways is allowed to be in use an any time.2 

The two logical runways on a paving have names that differ by 18. Thus a paving aligned due east-west will contain logical runway 09 and logical runway 27. 

The information you will need about each airport is simply a list of the available runways and their lengths. You will also need the minimum runway length required for your aircraft to land. 

To determine the best runway to land on, divide by the wind direction by ten and use the runway that is long enough whose name is closest to the result. 

Example: An airport has runways 04 (1200'), 09 (5000'), 15 (5000'), 22 (1200'), 27 (5000'), and 33 (5000').3 Your airplane needs 3500' to land. The wind direction is from 232 deg.4 

So, 232 divided by ten is 23. Runways that are long enough for your aircraft are 09, 15, 27, and 33. Of these, the one closest to 23 is 27. You would request and expect landing runway 27.5 

This is a rough outline of the steps a math project would take to guess the landing runway. Most pilots have no trouble hearing the weather advisory, glancing at the Jepp chart, and just knowing which runway should be in use. 




Often two digits are used, i.e. runway 9 is called 09. 
If a tower controller is present, he will identify and grant access to the runway in use. Your project will calculate the most likely expected runway. With no controller, the pilot should co-ordinate with any present traffic before using your project result. 
Notice that reciprocal runways occupy the same paving and perforce have the same length.  
Your project must be told whether the reported wind direction is from or toward. When the reported wind direction is toward, as it might be from a non-navigational source such as a local news broadcast, you must calculate the reciprocal from direction. 
If you had a plane that could stop in 1200' you would use runway 22.