A GPA looks like the simplest calculation on the web: turn letters into points, average them. I built a set of free GPA calculators (Gradelu), and almost all of the work went into five details that a naive version gets wrong. Every rule below comes from a published school or registrar page, linked where it is used.
1. The scale is data, not a constant
There is no single "4.0 scale". Two real tables:
| Letter | Rochester Christian University | Mount Holyoke College |
|---|---|---|
| A | 4.0 | 4.0 |
| A- | 3.7 | 3.67 |
| B+ | 3.3 | 3.33 |
| B- | 2.7 | 2.67 |
Three classes with the same credits, graded A-, A-, A: (3.7 + 3.7 + 4.0) ÷ 3 = 3.80 on the first table, (3.67 + 3.67 + 4.0) ÷ 3 = 3.78 on the second. Same transcript, different GPA.
A+ is another fork. Rochester's table has no A+ at all; the University of Illinois registrar counts A+ as 4.00. So the scale belongs in a table the user can see and switch, not in a hard-coded if:
// [letter, lowest percent (null = letters only), points] const PLUS_MINUS = [ ['A+', null, 4], ['A', 93, 4], ['A-', 90, 3.7], ['B+', 87, 3.3], ['B', 83, 3], ['B-', 80, 2.7], ['C+', 77, 2.3], ['C', 73, 2], ['C-', 70, 1.7], ['D+', 67, 1.3], ['D', 63, 1], ['D-', 60, 0.7], ['F', 0, 0], ]; 2. Percent bands have gaps
College Board's BigFuture table lists A 90–100, B 80–89, C 70–79, D 66–69 and E/F below 65. A score of exactly 65 is in no row, and neither is 89.5.
Matching ranges with >= min && <= max leaves those scores with no letter. Comparing against each letter's lowest cutoff covers every number:
function percentToLetter(percent, rows) { const banded = rows.filter(r => r[1] !== null).sort((a, b) => b[1] - a[1]); for (const [letter, min] of banded) if (percent >= min) return letter; return null; } // On the BigFuture table: 89.5 -> "B", 65 -> "F" (it does not reach D's 66). Whichever rule you pick for the gap, write it on the page. Users with a 65 deserve to know why they got an F.
3. Honors and AP bonuses stop at F
Weighted GPA adds points for harder classes. Charlotte-Mecklenburg Schools publishes a typical version: honors +0.5 (A = 4.5 … D = 1.5) and AP +1.0 (A = 5 … D = 2), and in both lists F = 0.
The one-liner points + bonus gives an F in an AP class 1 point. The guard is one condition:
const bonus = points > 0 ? (BONUS[level] ?? 0) : 0; It matters more than it looks. Take this term:
| Class | Grade | Credits | Points | Weighted |
|---|---|---|---|---|
| AP Biology | B | 1 | 3 | 4 |
| Honors English | A | 1 | 4 | 4.5 |
| Algebra II | C | 1 | 2 | 2 |
| AP US History | F | 1 | 0 | 0 |
| PE | A | 0.5 | 4 | 4 |
Unweighted: 11 quality points ÷ 4.5 credits = 2.44. Weighted: 12.5 ÷ 4.5 = 2.78. Give the F its AP bonus and the weighted GPA becomes 13.5 ÷ 4.5 = 3.00: a failed class has raised the GPA by more than a fifth of a point.
4. Weight by credits, and keep both numbers
A half-credit PE class should count half as much as a full class. So the calculator sums quality points (points × credits) and divides by credits, and it keeps the unweighted and weighted sums side by side, because colleges often recalculate from the unweighted one:
let credits = 0, qp = 0, wqp = 0; for (const c of courses) { const points = pointsFor(c.grade, scale); const bonus = points > 0 ? (BONUS[c.level] ?? 0) : 0; credits += c.credits; qp += points * c.credits; wqp += (points + bonus) * c.credits; } const unweighted = qp / credits; const weighted = wqp / credits; Showing the table above, row by row, is what makes users trust the result. A bare "2.78" invites "but my counselor said 3.0".
5. Rounding is a policy too
The weighted GPA above is 2.7777…. toFixed(2) prints 2.78. But the Illinois registrar says the GPA on its official transcript "is truncated, not rounded", which gives 2.77. If your calculator says 2.78 and the transcript says 2.77, the calculator looks wrong. Offer both, or say which one you use:
const truncate = (n, d = 2) => Math.floor(n * 10 ** d + 1e-9) / 10 ** d; (The 1e-9 stops floating point from turning a clean 2.8 into 2.79.)
Bonus: the "what do I need next term?" formula
The question students actually ask is about the future. With current GPA g over c credits, a target t and n new credits:
needed term GPA = (t × (c + n) − g × c) ÷ n From 2.5 over 30 credits to 3.2 with a 15-credit term: (3.2 × 45 − 2.5 × 30) ÷ 15 = 4.6, which is impossible on a 4.0 scale. A useful calculator says so and gives two honest answers instead. Straight A's reach (75 + 60) ÷ 45 = 3.00, and reaching 3.2 at a perfect 4.0 takes c × (t − g) ÷ (4 − t) = 30 × 0.7 ÷ 0.8 = 26.25 credits, so about 27.
All of this runs in the browser with no account: Gradelu's weighted GPA calculator shows the row-by-row table, and the grading scales page lists every table above with its source. Corrections are welcome in the comments.
This post was drafted by an AI agent for the Gradelu project; the rules, tables and numbers were checked against the linked sources and the calculator's own code before publishing.
