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:

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Question 1: Sentence Scan Java Program
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) 

 

****
****
****
Welcome To The SENTENCE SCAN PROGRAM!
****------
****---
****-
--- ---
----
Please enter the sentence to scan:
COVID-19 it's not over!
Here are some data about your sentence:
Word 1 has 8 characters.
Word 2 has 4 characters.
Word 3 has 3 characters.
Word 4 has 4 characters.
There are 4 words.
The longest word has 8 characters.
The shortest word has 3 characters.
The average word length is 4.75 characters.
Thank you for using The SENTENCE SCAN PROGRAM!
Figure 2 Sample output of Question1
Transcribed Image Text:**** **** **** Welcome To The SENTENCE SCAN PROGRAM! ****------ ****--- ****- --- --- ---- Please enter the sentence to scan: COVID-19 it's not over! Here are some data about your sentence: Word 1 has 8 characters. Word 2 has 4 characters. Word 3 has 3 characters. Word 4 has 4 characters. There are 4 words. The longest word has 8 characters. The shortest word has 3 characters. The average word length is 4.75 characters. Thank you for using The SENTENCE SCAN PROGRAM! Figure 2 Sample output of Question1
****
****
****
Welcome To The SENTENCE SCAN PROGRAM!
---- ****-- ---
*** *-------
****.
Please enter the sentence to scan:
My Quiz2 was graded.
Here are some data about your sentence:
Word 1 has 2 characters.
Word 2 has 5 characters.
Word 3 has 3 characters.
Word 4 has 6 characters.
There are 4 words.
The longest word has 6 characters.
The shortest word has 2 characters.
The average word length is 4.0 characters.
Thank you for using The SENTENCE SCAN PROGRAM!
Figure 1 Sample output of Question1
Transcribed Image Text:**** **** **** Welcome To The SENTENCE SCAN PROGRAM! ---- ****-- --- *** *------- ****. Please enter the sentence to scan: My Quiz2 was graded. Here are some data about your sentence: Word 1 has 2 characters. Word 2 has 5 characters. Word 3 has 3 characters. Word 4 has 6 characters. There are 4 words. The longest word has 6 characters. The shortest word has 2 characters. The average word length is 4.0 characters. Thank you for using The SENTENCE SCAN PROGRAM! Figure 1 Sample output of Question1
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY