Calculate battery percentage on LiPo battery?
Either you can try to find a mathematical model or (which is mostlikely much more ressources efficient) you implement a lookup table which in the end boils down to something similar to your case thingy but is more elegant code wise. Depending on the used env/language you should find enough ressources explaining the implementation of lookup tables.