Respuesta :
Answer:
Explanation:
The following code is written in Java. It has the main method (source process) and a function called fork() which contains the filter process as described in the question. fork() takes in the file information as a parameter and prints out the information to the screen. The test can be seen with the output in the attached image below.
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;
class Brainly {
public static void main(String[] args) {
String data = "";
try {
File myObj = new File("C:\\Users\\Gabriel2\\AppData\\Roaming\\JetBrains\\IdeaIC2020.2\\scratches\\input.txt"); //USE YOUR FILE LOCATION
Scanner myReader = new Scanner(myObj);
while (myReader.hasNextLine()) {
data += myReader.nextLine();
data += "\n";
}
myReader.close();
} catch (FileNotFoundException e) {
System.out.println("An error occurred.");
e.printStackTrace();
}
System.out.println("Original: \n" + data);
fork(data);
}
public static void fork(String data) {
String output = "";
for (int i = 0; i < data.length(); i++) {
if (Character.isUpperCase(data.charAt(i)) == true) {
output += Character.toLowerCase(data.charAt(i));
} else if (Character.isLowerCase(data.charAt(i)) == true) {
output += Character.toUpperCase(data.charAt(i));
} else {
output += data.charAt(i);
}
}
System.out.println("Modified: \n" + output );
}
}
![Ver imagen sandlee09](https://us-static.z-dn.net/files/de7/0c9e5181007167b4ea3b39fe6b310d3f.jpg)