Question: This is a small programming assignment using Javas HashSet data type and name it Books.java. The program will read words from two text files. Read

This is a small programming assignment using Javas HashSet data type and name it Books.java.

The program will read words from two text files. Read the words from one file, convert them to lower case, and put them into a HashSet, Read the words from the other file into another HashSet. You can read words easily using a Scanner, provided you change the delimiter that is used by the Scanner to separate tokens. Here is a command that you can use to set a Scanner, scanr, to read words from the file and discard everything else:

scanr.useDelimiter("('*[^a-zA-Z']'*|''+|^'|'$)+");

How many words were present in the first file that were not in the second file? How many words were present in the second file that were not in the first file? Putting all the words from the two files together, how many unique words were there in both files combined? (You can answer all of these questions using the HashSet API, without writing any loops.)

For example, here is the output:

File books/austin.txt contains 6346 unique words. File books/twain.txt contains 6089 unique words.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!