mardi 28 février 2017

Assign range to a letter

I'm actually wondering what is a best way to assign letter to range properly in C++.

For example, we have that scale:

enter image description here

We can do assignment in simpliest way:

if(a < 40)
  return 'T';
else if(a >= 40 && a < 55)
  return 'D';
else if(a >= 55 && a < 70)
  return 'P';
else if(a >= 70 && a < 80)
  return 'A';
else if(a >= 80 && a < 90)
  return 'E';
else if(a >= 90 && a <= 100)
  return 'O';

However, do you have some better ideas to make this?

Aucun commentaire:

Enregistrer un commentaire