I'm creating a subscription-based calculator in Java and I'm trying to figure out how to correctly prorate the value if the subscription.
My yearly subscription fee is a flat $120 per year (365 days). If a user wants only a 6 month subscription then the cost is $60. But let's say the subscriber signs on Jan. 15, 2011 and ends his subscription on June 30. That's only 5 months and 15 days. I need a formula that can correctly calculate the amount I need to charge. In this case it would be ~$55.00. It gets a little trickier if my user signs on Feb. 6th and ends their subscription Dec. 28.
Can anyone help?