Grade calculator for a project with four aspects
Because there are no holes you can simply have an array of "breakpoints".

int [] steps = new int[] { 2, 4, 13, 22, 31, 41, 54, 67, 80 };
int i;

for(i=0; i&lt;steps.length &amp;&amp; totalmark&gt;=steps[i]; i++);
grade = i==0 ? "U" : ""+i;
if(i&lt;steps.length) marksaway=steps[i]-totalmark; 
nextgrade=""+(i+1);