Determine how many stars to give from a portion of a score
<p>Math isn't one of my strong points, and I would like to know how to do this <strong>properly</strong> (I could hack somthing together, but it would be a mess):</p>

<ul>
<li>We score modules and give the user their score as a percentage</li>
<li>We want to reward these scores with a star rating, but only if they achieve a score greater than the module pass mark</li>
<li>The pass mark is variable</li>
<li>For future proofing, lets say the number of stars to be awarded is also variable</li>
<li>If they pass, I want them to always get at least 1 star</li>
</ul>

<hr>

<p>Example figures:</p>

<ul>
<li>Max Stars : 3</li>
<li>Pass mark : 75 %</li>
<li>User scores 75%, minimum passmark, so award 1 star</li>
<li>User scores 90%, would this be 2 stars ??</li>
</ul>

<p>Thanks guys.</p>

<hr>

<p>Integrated solution</p>

<p>this is what I went with :</p>

<pre><code>private const int NUMSTARS = 3;

public int starsFor(int pScore, int pPassMark)
{
    if(pScore &lt; pPassMark)
    {
        return 0;
    }
    else if (pScore == pPassMark)
    {
        return 1;
    }
    else
    {           
        return (int)Math.Ceiling(NUMSTARS * ((pScore - pPassMark) / (double)(100 - pPassMark))); 
    }
}
</code></pre>
