IN JAVA Write a program that reads a string entered at the command lineand counts the number
Question:
IN JAVA
Write a program that reads a string entered at the command lineand counts the number of characters or words. A blank space shouldbe used to delimit a word. Name the program StringCount and designit to be invoked using syntax as follows: StringCount –[c][w]user_string The hyphen (-) in the above syntax is used to denotethat counting options will be specified and the square brackets areused to denote counting options. A ‘c’ indicates that a charactercount should be done and a ‘w’ indicates that a word count shouldbe done. As an example, StringCount –cw "hello world" indicatesthat a character count and word count should be done on the string"hello world", and StringCount -w "hello world" indicates that aword count should be done on the string "hello world". Separatemethods must be used to perform the counts. Note that if the stringcontains blanks, as in the above example, then the string must bequoted and the quotes will not be part of the count. If a user runsthe program with incorrect syntax (e.g., the type of count is wrongor missing) the program should display an error message indicatingthe correct syntax (just use the above syntax). If you are using anIDE you may have to consult its documentation to learn how commandline arguments are entered. If you have trouble finding thisinformation you can always run the program from the commandline.
Data Structures and Algorithm Analysis in Java
ISBN: 978-0132576277
3rd edition
Authors: Mark A. Weiss