Menu

[solved]-Need Help Writing Java Program Textmod Analyze Text File 4 Commands Specified Add Number T Q39072617

I need help writing a java program (textmod) that will analyze atext file.

Here are the 4 commands:

-a <string> : If specified, will add the number of timesthe string appears to the start of each line within the file.
-b <int>: If specified, will output the words duplicated themost. If pos int is provided, the number of most common words willbe shown, starting with the most common.
-c <int>: If specified, will keep the shortest lines in thefile. Requires a positive int.
-d <int>: If specified will keep the longest lines in thefile. Requires a positive int.
c and d are mutually exclusive. If none of the commands areselected, the program will output the longest line in the file.

Example 1:
textmod fileA.txt
File Content:
door room room 4
room room

Output: “door room room 4”

Example 2:
textmod -b 2 -a “oom” fileB.txt
File content:
door door room room 4
room room

Result file:
2 door door room room 4
2 room room

Output: “room door”

Example 3:
textmod -b -c 2 fileC.txt
File content:
door room room room 6
door mat main 45
mat

Result file:
door mat main 45
mat

Output: “room”

Example 4:
textmod -d 1 fileD.txt
File content:
234 house houses doors
mat mat mouses
mooses 32

Result file:
234 house houses doors

Expert Answer


Answer to I need help writing a java program (textmod) that will analyze a text file. Here are the 4 commands: -a : If specified, … . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *