Answered step by step
Verified Expert Solution
Link Copied!

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

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

Oracle Solaris 11.2 System Administration (oracle Press)

Authors: Harry Foxwell

1st Edition

007184421X, 9780071844215

More Books

Students also viewed these Databases questions

Question

Define span of management or define span of control ?

Answered: 1 week ago

Question

What is meant by formal organisation ?

Answered: 1 week ago

Question

What is meant by staff authority ?

Answered: 1 week ago

Question

Discuss the various types of policies ?

Answered: 1 week ago

Question

5. Have you any experience with agile software development?

Answered: 1 week ago