Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Word Counting Program Write and test a Java program that will provide a count of the number of words, number of lines, and/or number of

image text in transcribed

image text in transcribed

image text in transcribed

Word Counting Program Write and test a Java program that will provide a count of the number of words, number of lines, and/or number of characters according to an option specified on command line along with the absolute path or relative path to the file upon which the program will operate. Th following character combinations are to represent appropriate options: -W The option -w is used to provide a count of the number of words in a file and the file name. -1 The option -l is used to provide a count of the number of lines in the file and the file name. -C The option -c is used to provide a count of the number characters in the file ar the file name. If the path to the file is provided without any of the above options, then the file name and a count of the number words, lines, and characters is written to the standard output device. Words are defined as a sequence of characters delimited by a space. A line is identified by the newline (" ") character. A character is valid utf-8 sequence of bytes. Examples of what the output may look like (actual numbers may be different): The program named "data" contains Amy looked at her watch. He was late. The sun was setting but Jake didn't care 1 Note that the space character between the words and the newline ( ) character are included in the count of characters. (1) Word count for a file named data C:\> java WordCount -w path\to\data File: data Word count: 16 (2) Line count for a file named data $ java WordCount -1 ~/path/to/data File: data Line count: 1 (3) Character count for a file named data File: data Character count: 80 (4) Line, word, and character count for a file named data $ java WordCount /path/to/data File: data Line count: 1 Word count: 16 Character count: 80 Your solution must include at least one additional method whose purpose is to count the number of words, number of lines, and number of characters in the file. In other words, 7 header comments import.... File: data Line count: 1 Word count: 16 Character count: 80 Your solution must include at least one additional method whose purpose is to count the number of words, number of lines, and number of characters in the file. In other words, 1/ header comments import... public class NameOfClass { public static void main(String[] args) { } // end main // Don't forget to document your code publie return_type/void methodThat Does TheCounting! } // end methodthatDoesTheCounting } ll end of class

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

Recommended Textbook for

Database Design Application And Administration

Authors: Michael Mannino, Michael V. Mannino

2nd Edition

0072880678, 9780072880670

More Books

Students also viewed these Databases questions

Question

4. What did you learn from this role-play?

Answered: 1 week ago