Average word length in a string
Java
Easy
streams
Task «Average word length in a string»
Write a program that reads a string of text containing words separated by spaces. Using the Stream API, find the average length of words in the string (number of letters). Output the result rounded to two decimal places.
Input Format
One line containing words of Latin letters separated by spaces. The length of the string does not exceed 1000 characters.
Output Format
One number — the average word length, rounded to two decimal places.
Examples
Example 1
INPUT
hello world
OUTPUT
5.00
Example 2
INPUT
python is great
OUTPUT
4.33
main.java