Question: This is done using Java [10 marks] Consider the program skeleton below: import java.io.*; import java.util.*; public class CopyFileCapitalized { public static void main(String[] args)

This is done using Java

[10 marks] Consider the program skeleton below: import java.io.*; import java.util.*; public class CopyFileCapitalized { public static void main(String[] args) throws Exception { String censoredWords[] = {"ABC", "XYZ"}; //add code (1) } private static String replaceCensoredWords(String line, String[] censoredWords){ //add code (2) } } Write code at (2) to check line word by word and replace those which are listed in the censoredWords array with "..." (three dots). The method should eventually return the same line of text after replacing the censored words. One way to check the words in line is to use the following statement and then read the words from the input stream using next(). Scanner input = new Scanner(line); Write code at (1) to read the contents of a text file (e.g., source.txt) line-by-line, replace censored words using the replaceCensoredWords method, convert the text to uppercase, and write it to a destination file (e.g., destination.txt). Dont worry too much about writing code to handling exceptions (just declare them in method headers). Samples for source.txt and destination.txt can be downloaded from Canvas.

Source:

abc def ghi abcdef 123 jkl mno pqr 456 stu vw xyz 789 vwxyz

Destination

... DEF GHI ABCDEF 123 JKL MNO PQR 456 STU VW ... 789 VWXYZ

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!