Ready to begin
No records have been processed. Start with Next step.
Instead of dividing the class into above and below average, we can create four grade bands. First discover the lowest and highest actual Mathematics marks. Only then can we set fixed bands and classify students.

Read the current record, check the explanation, and watch the variables. Use Back to revisit any step.
Ready
No records have been processed. Start with Next step.
Start at the first step. Watch the current row and the values we remember.
Minimum = 101
Maximum = -1
for each row X in Scores {
if (X.Mathematics < Minimum) { Minimum = X.Mathematics }
if (X.Mathematics > Maximum) { Maximum = X.Mathematics }
}These initial values work because valid marks lie from 0 to 100. The first value, 68, updates both variables. Use two separate if statements, not if / else. Starting both variables from the first real row is another safe approach for a nonempty dataset.
Maximum − Minimum = 97 − 42 = 55 is the numerical difference. There are 97 − 42 + 1 = 56 possible integer marks when both ends are included. Four equal groups of 14 integer values give the following bands.
| Grade | Inclusive Mathematics band | Actual students |
|---|---|---|
| D | 42–55 | 3 |
| C | 56–69 | 9 |
| B | 70–83 | 10 |
| A | 84–97 | 8 |
for each row X in Scores {
if (X.Mathematics >= 84) { Grade = "A" }
else if (X.Mathematics >= 70) { Grade = "B" }
else if (X.Mathematics >= 56) { Grade = "C" }
else { Grade = "D" }
record (X.CardNo, Grade)
}These are the lecture’s example bands, not an official grading policy. Equal-width intervals do not promise equal student counts. Boundary choices must be explicit; a new dataset may require different bands. If min equals max, handle that separately rather than pretending there is a spread.
Why does the inclusive count use +1?
42 and 97 are both included. The difference counts gaps; +1 counts the integer values.
Where do 55,56,69,70,83,84 go?
55→D; 56 and 69→C; 70 and 83→B; 84→A.
Why can the first mark update both min and max?
Before seeing any marks, both limits are placeholders. The first real mark is both the smallest and largest seen so far.
Does each band have 7 or 8 students?
No. The actual counts are A 8, B 10, C 9 and D 3.
Can Minimum start at zero for valid nonnegative marks?
That would stop it updating when every mark is positive. Use a sufficiently high bound or the first real value.