How to convert this to an equation?

39 Views Asked by At

I need to convert this to an equation so that when a user selects a percentage between 0% and 100% it'll return the correct decimal number based on this scale. As you can see the numbers on the ends only have a range of 10% and the center have 20%

0% = 0 <10% = 1 10-29% = 2 30-49% = 3 50-69% = 4 70-89% = 5 90-100% = 6

This should be simple, but I keep over thinking it.

2

There are 2 best solutions below

0
On

HINT:

Try converting percentages to decimals and write it as a piecewise function with domain restrictions.

0
On

Here's one way which is something of a cheat (it ignores the $0\%$ case). Let $p\in (0,100]$ denote the percentage. Then the corresponding score is given by $$ \left\lfloor \frac{p+10}{20}\right\rfloor +1, $$ where $\lfloor\,\rfloor$ denotes the floor function, which returns the greatest integer that is less than the input.