Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started