Question: Java Programming Write a static method named wordCountAndFixSpaces(), which takes a Scanner object for a file as a parameter and reports various statistics about the
Java Programming
Write a static method named wordCountAndFixSpaces(), which takes a Scanner object for a file as a parameter and reports various statistics about the file. The method should generate the number of lines, the total number of words, the total number of characters, and the longest word (*Note: regard "can't" as one word and disregard any marks or signs such as ?, ", ., -, , \t, etc. when counting tokens). The text may contain multiple spaces and tabs. Those spaces should be reduced into a single space between each word in order to print them to the console. Your program can assume that the text file may contain at least one line of input.
The input file contains the following text:
"Writing is an exercise."
You get better and faster with practice.
If you were going to run a marathon a year from now,
would you wait for months and then run 26 miles cold?
No, you would build up slowly, running most days.
You might start on the flats and work up to more
demanding and difficult terrain. To become a writer, write.
Don't wait for that book manuscript or that monster external-review report
to work on your writing.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
