Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions