Question: Assume one-or-more empty lines separate paragraphs in a text file. This homework requires you to develop a Java program that accepts 2 command-line arguments (i.e.,

Assume one-or-more empty lines separate paragraphs in a text file. This homework requires you to develop a Java program that accepts 2 command-line arguments (i.e., arguments to the main method):

1. The first command-line argument will be the path to the text file to be processed

2. The second command-line argument will be a Boolean flag (true or false). If this flag is false then word counts should simply be printed as zero. If this flag is true then word count must be computed and printed.

Print the first and last line (if different) of a paragraph in a given HTML format. Note that if first and last line is identical (i.e., a paragraph has only 1 line) then print just the first line.

Print count of words in each paragraph, if the second commandline argument is true. If you don't implement this functionality then just 0 (zero) as word count.

Tips:

The program is relatively straightforward. Use Scanner.nextLine() method to read lines from a text file.

For word count, create a Scanner for each line and use Scanner.next() to extract words

Sample text file input:

This is the first line of first paragraph

This is the second line of first paragraph

This is the third line of first paragraph

This is the last line of first paragraph

Second para line 1

Second para line 2

A one line third paragraph

This paragraph is going to have 5 lines. Line 1 of 5

This paragraph is going to have 5 lines. Line 2 of 5

This paragraph is going to have 5 lines. Line 3 of 5

This paragraph is going to have 5 lines. Line 4 of 5

This paragraph is going to have 5 lines. Line 5 of 5

This is the last, 1 line paragraph in this file.

Sample output:Assume one-or-more empty lines separate paragraphs in a text file. This homework

Example word count output: Note that the 2hd command-line argument is true. Hence, word counts should be reported. If you are not implementing valid English word counts, then print zero instead java Homeworkl base case.txt true First and last lineWord counts/tr> trtd>This is the first line of first paragraph This is the last line of first trtd>Second para line 1 Second para line 2/tdxtd>Words: 8 English words: trtd>A one 1line third paragraph X/td>xtd Words: 5 English words: 5Xtr> paragraph Words: 32 English words: 32K/td>Xtr> A

This paragraph is going to have 5 lines. Line 1 of 5 This paragraph is going to have 5 lines. Line 5 of 5Words: 60 English words 45 This is the last, 1 line paragraph in this file.
Words: 10 English 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!