Program 2 Unit 1
Program 2 Unit 1
Assignment unit1
import java.util.HashMap;
import java.util.Scanner;
Explanations
User input: The program prompts the user to enter text and stores it in the
text variable.
Character count: it calculates the length of the text string and displays the
character count.
Word count: it uses split to split the text into words based on spaces and
counts the number of elements in the resulting array.
Word frequency: The user enters a word, its lowercase version is compared
against each lowercase word in the text, and the frequency is displayed.
Reference