#C225. Adjust Screen Brightness Based on Ambient Light Level
Adjust Screen Brightness Based on Ambient Light Level
Adjust Screen Brightness Based on Ambient Light Level
You are given a single floating-point number representing the ambient light level. Based on this value, you are to compute the corresponding screen brightness percentage according to the following rules:
- If the light level is negative, you should output the error message:
Light level cannot be negative
. - If \(L < 20.0\), the brightness is \(10\)%.
- If \(20.0 \le L < 50.0\), the brightness is \(30\)%.
- If \(50.0 \le L < 80.0\), the brightness is \(60\)%.
- If \(80.0 \le L < 100.0\), the brightness is \(90\)%.
- If \(L \ge 100.0\), the brightness is \(100\)%.
Your program should read the input from standard input and write the result to standard output.
inputFormat
The input consists of a single line containing a floating-point number representing the ambient light level.
outputFormat
Print a single integer representing the screen brightness percentage according to the rules above. If the ambient light level is negative, print the error message: Light level cannot be negative
.
-5.0
Light level cannot be negative