Question: Write a Java program that reads an input file containing several lines of text. The program should store each word or phrase using Collection strategies

Write a Java program that reads an input file containing several lines of text. The

program should store each word or phrase using Collection strategies and provide the

user with an interface to search the input text.

Your program should implement the following functionality:

1. Prompt the user to enter the name and location of the input file. User input:

c://project//input.txt

2. List each words or phrases in the input file together with the line numbers of

their appearance and their frequency of occurrence. For exapmle:

SAMPLE INPUT:

A binary tree is made of nodes, where each node contains a "left" pointer, a "right" pointer, and a data element. The "root" pointer points to the topmost node in the tree.

OUPUT

Word Frequency Lines

A 4 1, 2

Binary 2 1

Tree 2 1, 2

3. List all lines of text by their line #.

4. Allow the user to enter a word or phrase to search. The users search must

retrievable for the duration of the programs execution

a. Programming //Exact Match

b. Prog* //Matches all words that start with Prog

c. *ing //Matches all words that end with ing

d. *gram* //Matches all words that contain the sequence gram

e. Pro*ing //Matches all words that start and end with Pro and ing

f. I love programming //Matches the phrase

5. The users search should display the following:

a. A listing of all words that match.

b. The frequency of each match.

c. The line number of each matching word

d. The matching lines of text from the input file.

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!