Overview In this task, you should write a program that asks the user to enter one or more sentences. The program counts and prints on the screen how many sentences, words and characters the user wrote. Task Write a java program that prompts the user to write a text with one or more sentences. The program will then print on the screen how many sentences, words and characters the user entered. You can assume that: • one sentence: always ends with a period (.), an exclamation point (!), a question mark (?) or the user presses 'enter' on the keyboard. • words: always separated by a space () or the user presses 'enter' on the keyboard. • a sign: is any character in the text (string) that the user enters. Tip • StringTokenizer, String.split and / or Scanner. Output attached by pic
Overview
In this task, you should write a program that asks the user to enter one or more sentences. The program counts and prints on the screen how many sentences, words and characters the user wrote.
Task
Write a java program that prompts the user to write a text with one or more sentences. The program will then print on the screen how many sentences, words and characters the user entered.
You can assume that:
• one sentence:
always ends with a period (.), an exclamation point (!), a question mark (?) or the user presses 'enter' on the keyboard.
• words:
always separated by a space () or the user presses 'enter' on the keyboard.
• a sign:
is any character in the text (string) that the user enters.
Tip
• StringTokenizer, String.split and / or Scanner.
Output attached by pic
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 2 images