analyzeParagraphs
Category: Line-Based File Processing
Author: Stuart Reges
Book Chapter: 6.3
Problem: analyzeParagraphs
Write a static method called
analyzeParagraphs that takes as a parameter a Scanner containing a text file
and that produces output that describes the paragraph structure of the file,
returning the maximum number of lines in any given paragraph. Each
paragraph in the input file will be terminated by the text "" on a line
by itself. For example, consider the following input file:
This is an example of an input file
with four different paragraphs.
The second paragraph is the longest
with three lines, so your method should
return 3 when processing this file.
The third paragraph was empty. This one is just short.
The method should count the number of lines in each paragraph and report
that information to System.out. For example, if the input above is stored
in a Scanner called input and we make the following call:
int max = analyzeParagraphs(input);
It should produce the following output:
2-line paragraph
3-line paragraph
0-line paragraph
1-line paragraph
It would assign max the value 3 because the method returns the maximum
number of lines in any given paragraph. You must exactly reproduce the
format of this output. You may assume that the input file has no blank
lines, that it contains at least one paragraph, and that each paragraph is
terminated by a line containing just "".