Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

DB2 Universal Database V7.1 Application Development Certification Guide

Authors: Steve Sanyal, David Martineau, Kevin Gashyna, Michael Kyprianou

1st Edition

0130913677, 978-0130913678

More Books

Students also viewed these Databases questions