Average of Three Integers
Mediumjava
Read three integers and print their average as a decimal number rounded to exactly two places.
Input: three integers separated by whitespace.
Output: one line — the average with two digits after the decimal point.
Example 1
Input
1 2 4
Output
2.33
Example 2
Input
10 20 30
Output
20.00
- -1000000 <= each integer <= 1000000
Hint 1
Divide by 3.0 (a double) so the result keeps its fraction.
Hint 2
String.format(Locale.US, "%.2f", average) formats to two decimals with a dot.
The sum of three ints is an int; dividing by 3.0 promotes the calculation to double so no precision is lost. String.format with Locale.US and "%.2f" prints exactly two decimal places with a dot regardless of the machine's locale.