Possible Duplicate:
Proportionately distribute (prorate) a value across a set of values
I have been looking for an algorithm to distibute the total amount monthly based on the number of days of the year in C# so that the sum of all proportons is equal to the total value.
A date range within a year, and total amount is given.
Example:
for a value 19550 and date range 9/1/2011 to 6/30/2012
September 1,929.28
October 1,993.59
November 1,929.28
December 1,993.59
January 1,993.59
February 1,864.97 - 28 days
March 1,993.59 - 31 days
April 1,929.28 - 30 days
May 1,993.59
June 1,929.28
but the total is 19,550.04 which is .04 more than the total.