finding average price of two lots of shares

Sorry, not a math guy, this might be an overly simple question for the lot of you, but it's a calculation that I'll have to do a lot possibly, so please show me the best way to do it. If I have $1265$ shares of XYZ Company that were bought at an average price of $\$3.95$, and$3949$shares of the same XYZ Company that were bought at$\$5.03$, how can I find the average combined price for the $5214$ ($1265 + 3949$) shares? Thanks.

-
What kind of programmer are you? This is arithmetics! –  JMCF125 Nov 22 '13 at 23:09

The cost of your $1265$ shares was $(1265)(3.95)$.
The cost of your $3949$ shares was $(3949)(5.03)$.
Total cost: $(1265)(3.95)+(3949)(5.03)$.
Total shares: $1265+3949$.
Average cost per share: $\dfrac{(1265)(3.95)+(3949)(5.03)}{1265+3949}$.