Answered step by step
Verified Expert Solution
Question
1 Approved Answer
these are the words that are in seperate file Write a Java program to perform some operations on the text file of the user's choice.
these are the words that are in seperate file
Write a Java program to perform some operations on the text file of the user's choice. Your program should first ask the user for their file name including the path and then present the user with the following menu of choices: Choose an item from the menu: 1. Count the number of words in the file. 2. Count the number of characters in the file. 3. Remove all occurrences of a word from the file. 4. Replace all occurrences of a word in the file with another word. For each of the menu choices, write a method to do the work: - The methods for the first 2 choices should be passed a string containing the properly formatted file path and file name for the file entered by the user. These first 2 methods should return an int representing the count so the count can be displayed to the console for the user by the calling method. - For the last two choices, the methods should be passed a string containing the properly formatted file path and file name for the file entered by the user. They should both be void methods that do their job by writing the resulting text after the operation to a new file. The new file should be named newfile.txt and stored in the same folder as the user's file after it is written. Make sure you ask the user the word they want to remove or replace. If replacing a word, the user should also be asked what word they want to replace the old word with. Note: I would recommend creating a simple folder under the root of c: \ to hold all your text files. attack at dawn bring the big guns do not back down we are counting on youStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started