I was asked to write a program that should do thefollowin: 1. Should be run from
ID: 3615356 • Letter: I
Question
I was asked to write a program that should do thefollowin: 1. Should be run from the command line using command-linearguments to provide the input and output filenames. 2. The application should display an appropriate error messageif the user forgets to enter the input and output file names or ifthe files are not found. 3. The application should open the input file and read eachline of the file' 4.For each line read, the application should: a. determine the total number of characters in the line,including white-space characters. b. determine the number of times the number 4 appears in theline. c. replace all occurrances of the string "this" with "That",and finally d. reverse the order of the characters in the line. 5. The output file should contain the same number of lines asthe input file. 6. The application should close any open files beforeexiting. EXAMPLE OF THE PROGRAM INPUT FILE CONTENT we shall count until 4 before this application finishes 4 cats and 4 mice go up and down this and that is what that or this is about this4cats OUTPUT FILE CONTENT 55, 1, sehsinif noitacilppa tahT erofeb 4 litnu tnuoc llahsew 32, 2, nwod dna pu og ecim 4 dna stac 4 43, 0, tuoba si tahT ro taht tahw si taht dna tahT 9, 1, stac4tahT Please any help would be appriciated, I would ratelivesaver I was asked to write a program that should do thefollowin: 1. Should be run from the command line using command-linearguments to provide the input and output filenames. 2. The application should display an appropriate error messageif the user forgets to enter the input and output file names or ifthe files are not found. 3. The application should open the input file and read eachline of the file' 4.For each line read, the application should: a. determine the total number of characters in the line,including white-space characters. b. determine the number of times the number 4 appears in theline. c. replace all occurrances of the string "this" with "That",and finally d. reverse the order of the characters in the line. 5. The output file should contain the same number of lines asthe input file. 6. The application should close any open files beforeexiting. EXAMPLE OF THE PROGRAM INPUT FILE CONTENT we shall count until 4 before this application finishes 4 cats and 4 mice go up and down this and that is what that or this is about this4cats OUTPUT FILE CONTENT 55, 1, sehsinif noitacilppa tahT erofeb 4 litnu tnuoc llahsew 32, 2, nwod dna pu og ecim 4 dna stac 4 43, 0, tuoba si tahT ro taht tahw si taht dna tahT 9, 1, stac4tahT Please any help would be appriciated, I would ratelivesaverExplanation / Answer
please rate - thanks import java.util.*; import java.io.*; public class untitled { /** * @param args the command linearguments */ public static void main(String[] args) {String text,reversed; int fours,ch,i,n; if(args.length!=2) System.out.println("All files not defines-program aborting"); else try {Scanner input=new Scanner(newFile(args[0])); try {PrintStream output=newPrintStream(new File(args[1])); while(input.hasNextLine()) {text=input.nextLine(); i=0; fours=0; ch=0; System.out.println(text); n=text.length(); while(iRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.