{
  "schemaVersion": 1,
  "slug": "cumulative-gpa-calculator",
  "category": "productivity",
  "kind": "implementation",
  "independentValidation": false,
  "implementationHash": "50a082f761cac2a986d53939a0bda72c86402647592e7df892a4b7aae15a19db",
  "provenance": "Generated from the calculation contract used by the published page. Publication is not external validation.",
  "sourceFiles": [
    "data/calculators/cumulative-gpa-calculator.json",
    "src/engine.js"
  ],
  "runtimeSource": "/sources/engine.txt",
  "runtimeHash": "5c888d8898afbdee36267bb9977829e1e2ac568f6677c8ee87469c139864645c",
  "scope": "The compute function records implemented equations, constants, lookup tables and custom rules. Inputs record defaults and allowed values; outputs record precision and units. Defaults are examples, not recommendations. General background references are not evidence for this specific algorithm.",
  "publishedFormula": {
    "formula": "G_s = (G_t × (C + S) − G_0 × C) ÷ S",
    "vars": [
      [
        "G_t",
        "Target GPA"
      ],
      [
        "G_0",
        "Current GPA"
      ],
      [
        "C",
        "Credits earned"
      ],
      [
        "S",
        "Credits this semester"
      ]
    ],
    "note": "If G_s > 4.0 the target is not achievable; maximum GPA = (G_0 × C + 4 × S) ÷ (C + S); GPA is rounded to two decimals."
  },
  "externalEvidence": null,
  "contract": {
    "compute": "const empty={neededSemesterGpa:null,achievable:null,pointsNeeded:null,maxAchievableGpa:null,note:null};const v=[currentGpa,creditsEarned,semesterCredits,targetGpa].map(Number);if(v.some(n=>!Number.isFinite(n))||currentGpa<0||currentGpa>4||!Number.isInteger(creditsEarned)||creditsEarned<0||!Number.isInteger(semesterCredits)||semesterCredits<=0||targetGpa<0||targetGpa>4)return{...empty,__error:'inputError'};const targetPoints=targetGpa*(creditsEarned+semesterCredits),currentPoints=currentGpa*creditsEarned,pointsNeeded=targetPoints-currentPoints,neededSemesterGpa=pointsNeeded/semesterCredits,maxAchievableGpa=(currentPoints+4*semesterCredits)/(creditsEarned+semesterCredits);return{neededSemesterGpa,achievable:neededSemesterGpa<=4?(neededSemesterGpa<=0?'Already at or above target':'Yes, achievable'):'No — the target needs above a 4.0 this semester',pointsNeeded,maxAchievableGpa,note:'GPA is usually rounded to two decimals, and some programmes weight honours and AP courses differently'};",
    "inputs": [
      {
        "name": "currentGpa",
        "type": "number",
        "default": 3.2,
        "min": 0,
        "max": 4,
        "step": 0.01,
        "slider": true
      },
      {
        "name": "creditsEarned",
        "type": "number",
        "default": 60,
        "min": 0,
        "max": 400,
        "step": 1,
        "slider": true
      },
      {
        "name": "semesterCredits",
        "type": "number",
        "default": 15,
        "min": 0,
        "max": 60,
        "step": 1,
        "slider": true
      },
      {
        "name": "targetGpa",
        "type": "number",
        "default": 3.5,
        "min": 0,
        "max": 4,
        "step": 0.01,
        "slider": true
      }
    ],
    "outputs": [
      {
        "name": "neededSemesterGpa",
        "precision": 3,
        "unit": ""
      },
      {
        "name": "achievable",
        "precision": 0,
        "unit": "",
        "type": "text"
      },
      {
        "name": "pointsNeeded",
        "precision": 1,
        "unit": ""
      },
      {
        "name": "maxAchievableGpa",
        "precision": 3,
        "unit": ""
      },
      {
        "name": "note",
        "precision": 0,
        "unit": "",
        "type": "text"
      }
    ],
    "interpret": null
  }
}
