Write a java program correctly to read a sentence and display the length of each word, the number of words in the sentence, the length of the shortest and longest words and the average length of the words. Here is an example of how your program should behave (assume that the data in green has been entered by the user). Notes:
Question 1: Sentence Scan Java
Write a java program correctly to read a sentence and display the length of each word, the number of words in the
sentence, the length of the shortest and longest words and the average length of the words. Here is an
example of how your program should behave (assume that the data in green has been entered by the
user).
Notes:
- You can assume that a sentence will always fit within a line: so, you can used nextLine() to read
the sentence.
- A sentence will always finish with a punctuation mark (e.g., a period, a question mark, ...) which
should not be considered as part of the last word.
- A word is any sequence of non-white characters. For example, I’ll is 1 word, but I will is
considered 2 words.
- You can assume that the words will always be followed by 1 and only 1 white space (except for the
last word which is followed by punctuation)
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images