I want to calculate the amount to charge my customers, when they buy licenses of my product.
I sell it in ranges of licenses:
- 1-10 : $50/user
- 11-20 : $40/user
- 21-30 : $30/user
- 31-50 : $20/user
So when someone purchases 136 licenses, I will charge him:
50 x 2 x $20 = $2000
30 x 1 x $30 = $900
6 x $50 = $300
I'm looking for an algorithm on how to process the given number and break it into number of occurrences in a range.. How can I do this in plain C# or LINQ?
------------ EDIT ----------------------------
I started a less confusing question (http://stackoverflow.com/questions/2685391/algorithm-for-fogbugz-pricing-scheme) and I got the answer I've been looking for.
Thank you all..