Question: write a program that compares two files. First, the program will read two file names from the user. Next, the program should count how many

write a program that compares two files. First, the program will read two file names from the user. Next, the program should count how many words in the first file appears in the second. After that it should print a report of the comparison of two files.

The following outlines a plan to solve this problem.
1. Create two Scanner objects to read the two files.
2. Read all the words in the second file and add them to an ArrayList
3. Read each word in the first file and check to see whether it is in the ArrayList.

The outline provided does not contain all details. For an example, as you see from the output you have to perform two counts. You also have to properly handle Exceptions.

Below is a sample of how the program should run: 


 Enter the path for the first file: input1.txt Enter the path for the second file: input2.txt First file has 

Enter the path for the first file: input1.txt Enter the path for the second file: input2.txt First file has 45 words. 38 of them are found in the second.

Step by Step Solution

3.38 Rating (151 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

To create a Java program that follows the outlined steps and correctly compares two files as demonstrated by the sample output you need to follow thes... View full answer

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 Programming Questions!