How can I tell the contributing value for each portion of a weighted average?

For example if I have a set of values each with a weight I would multiply each of those values by its weight, total them and then divide by the total of the weights.

How can I determine what each individual value contributed to the final total?

(this is ultimately a programming problem so even a somewhat complex solution is OK - or if you know how to show it in C or VB that is fine too)

Thank you!