Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Anyone can help me how to solve this question please. Assume one-or-more empty lines separate paragraphs in a text file. This homework requires you to

Anyone can help me how to solve this question please.

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.

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

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.

Sample 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:

image text in transcribed

iava Homeworkl base case.txt false First and last lineWord counts/tr> trxtd> Second para 1ine 1 Second para line 2xtd>Words: 0 English words: A one line third paragraph x/tdXtr> line of first paragraph Words0 English words: 0 0 trxtd>This paragraph is going to have 5 lines. Line 1 of 5 This paragraph is going to have 5 lines. Line 5 of 5Words: 0 English words: 0xtr> xtd>This is the last, 1 line paragraph in this file.Words: 0 English words 0 /table>
This is the first line of first paragraph This is the last
Words: 0 English words 0

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored 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