Relation between grades and letter grades

Marcos Pires

New member
Joined
Oct 11, 2016
Messages
5
Hello again,

Today I've come with another question that I got from a programming assignment, which I don't have to solve with math but would like to. I have a letter grade scale and although I could hard-code it in a simple way, I was wandering if this can be expressed with a function. I'm not looking for a shake and bake reply, just a direction of what I should be looking for if this can indeed be expressed in math. The grades letter are expressed by the number in parentheses

Grade system
80 to 100 A(65)
70 to 79 B(66)
60 to 69 C(67)
50 to 59 D(68)
0 to 49 F(70)

In other terms

Fx = 65 where X={80 to 100}
Fx = 66 where X={70 to 79}
Fx = 67 where X={60 to 69}
Fx = 68 where X={50 to 59}
Fx = 70 where X={0 to 49}

I really doubt this can be expressed in math but its worth a try -=) thanks for the help in advance
 
Last edited:
Given the stipulations laid out here, I think that using a series of if-elseif statements checking the incoming score against integer literals is probably the best way to go. Although, I'm curious about one thing. Your ranges don't match up, so what happens if your function gets called with an argument of, say, 52? That's not in any of the given ranges, so what would/should it return?
 
Hello,

Sorry, I've mistype the ranges. I've fixed it now. Yes I could use an if/else ( a switch in the case) but that would be the easy way out. Also, the number representation for the letters, A being 65 for example is not a random number, its the letter representation is ascii, something that later I can translate to an actual "A"
 
Hello,

Sorry, I've mistype the ranges. I've fixed it now. Yes I could use an if/else ( a switch in the case) but that would be the easy way out. Also, the number representation for the letters, A being 65 for example is not a random number, its the letter representation is ascii, something that later I can translate to an actual "A"

Unfortunately, sometimes "the easy way out" is the only way to go. And this is one of those times. I can't think of any programmatic way to relate your given input ranges to the output values.
 
Top