Question: PROMPT: Add a new method to ArrayTools called filter. Make this method accept a String array. Change all the Strings that are longer than 5

PROMPT:

Add a new method to ArrayTools called filter. Make this method accept a String array. Change all the Strings that are longer than 5 characters to uppercase.

DEMO.3:

import java.util.Scanner; file thats gonna be ran : public class Demo3 { public static void main(String[] args) { Scanner keyboard = new Scanner(System.in); System.out.println("How many strings?"); int size = keyboard.nextInt(); keyboard.nextLine(); String[] arr = new String[size]; for (int subscript = 0; subscript < size; subscript++) { System.out.println("Enter a value:"); arr[subscript] = keyboard.nextLine(); } ArrayTools.filter(arr); ArrayTools.printAll(arr); } File printall:
import java.util.Scanner; public class ArrayTools { public static int printAll(String[] input) { int len = input.length; int[] numbers = new int[4]; for (int subscript = 0; subscript < len; ++subscript) { System.out.println("[" + subscript + "]: " + input[subscript]); } return len; } public class Demo2 { public static void main(String[] args) { Scanner keyboard = new Scanner(System.in); System.out.println("How many strings?"); int size = keyboard.nextInt(); keyboard.nextLine(); String[] arr = new String[size]; for (int subscript = 0; subscript < size; subscript++) { System.out.println("Enter a value:"); arr[subscript] = keyboard.nextLine(); } String[] destination = new String[size]; System.out.println("copy/print test 1"); ArrayTools.copy(arr, destination); ArrayTools.printAll(destination); destination = new String[size + 1]; System.out.println("copy/print test 1"); ArrayTools.copy(arr, destination); ArrayTools.printAll(destination); destination = new String[size - 1]; System.out.println("copy/print test 1"); ArrayTools.copy(arr, destination); ArrayTools.printAll(destination); destination = new String[5]; System.out.println("copy/print test 1"); ArrayTools.copy(arr, destination); ArrayTools.printAll(destination); destination = new String[size * size]; System.out.println("copy/print test 1"); ArrayTools.copy(arr, destination); ArrayTools.printAll(destination); } } public static void copy(String src[], String dest[]){ if(src.length > dest.length){ System.out.println("Error: Second array isn't big enough. First array size: " + src.length + " Second array size: " + dest.length); } else{ for(int i = 0;i< src.length; i++) dest[i] = src[i]; } } }

Needs to be ran with a code in java with the other two array tools involved. Please and thank you very much.

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!