Your task is to calculate the amount you have to pay for prescribed medication at a pharmacy in Germany. The amount is simply based on the full price of the item, which will be your input. It is a decimal number with exactly two fractional digits (ex. 5.43). You can assume it's strictly positive. Your task is to calculate the amount a customer has to pay, according to this function:
$$ A(x)=\begin{cases} x&\text{if } x\le 5\\ 5&\text{if } 5\le x \le 50\\ 0.1x&\text{if }50\le x \le 100\\ 10&\text{if }100 \le x \end{cases} $$ or equivalently $$ A(x)=\min(x,\min(\max(0.1x,5),10)) $$
The result must be rounded to two decimal places (half up). If these are 0, they may be skipped from the output. There must not be more than 2 decimal places. You can take numbers or strings as input and output, but be aware of inexact floating point representations.
Use a comma or a point as the decimal separator.
Test cases
(Whitespace just for readability)
5.00
, 5.0
and 5
are all ok.
4.99 -> 4.99
5.00 -> 5.00
5.05 -> 5.00
10.00 -> 5.00
49.00 -> 5.00
50.00 -> 5.00
50.04 -> 5.00
50.05 -> 5.01
50.14 -> 5.01
50.15 -> 5.02
99.84 -> 9.98
99.85 -> 9.99
99.94 -> 9.99
99.95 -> 10.00
100.00 -> 10.00
1000.00 -> 10.00
5.00
might be represented as5.0
or5
etc. Is a function that returns floats not valid? \$\endgroup\$