6

I have score ranges min score = 40 and max score = 60. I have same gpa ranges too 1.00 - 1.99.

Which formula I can use to calculate the gpa. Like If I entered 45 then it should print 1.25.

Range of score and grade can be different.

P.S. I am a web developer, and I am a little poor in Math. I need to apply this formula in my coding.

2 Answers2

6

Let the following denote:

  • $S$: input score
  • $S_{min}$: min score
  • $S_{max}$: max score
  • $G_{min}$: min gpa
  • $G_{max}$: max gpa
  • $G$: output gpa

Then your formula is:

$$G=\frac{(S-S_{min})\cdot(G_{max}-G_{min})}{S_{max}-S_{min}}+G_{min}$$

barak manos
  • 43,109
1

The general form of this question on how to map the interval $[a,b]$ onto the interval $[c,d]$ was answered in Shift numbers into a different range (including a derivation) using the following expression $$f(t) = c + \left(\frac{d-c}{b-a}\right)(t-a)$$ So to map the interval $[40,60]$ onto the interval $[1.0,2.0]$ use \begin{align} f(t) &= 1.0 + \left(\frac{2.0-1.0}{60-40}\right)(t-40) \\ &= 1.0 + \left(\frac{t-40}{20}\right) \end{align} Using your example score of $45$ \begin{align} f(45) &= 1.0 + \left(\frac{45-40}{20}\right) \\ &= 1.25 \end{align}