020-002-005
Set Management: Unique Words
Easy
Problem Description
Set Management: Unique Words
In this problem, you will create a program that adds multiple words to a HashSet to eliminate duplicates, then displays the unique word count and word list to standard output.
Learning Objective: Eliminate duplicates with HashSet and check existence of unique elements
Create a program to extract words from text and count unique words. Using the "no duplicates" characteristic of HashSet, only one instance of a word is saved in the set even if the same word appears multiple times. Use the contains() method to check the existence of a specific word.
Input
Line 1: Number of words (integer, 1-15 words)
Lines 2~N+1: Word (string)
Output
Word Analysis:
Total Words: [total word count]
Unique Words: [unique word count]
Unique Word List:
[word 1]
[word 2]
...
```java
Word list displayed in addition order.
Ready to Try Running Code?
Log in to access the code editor and execute your solutions for this problem.
Don't have an account?
Sign Up