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. ArrayTools: public class ArrayTools { public static int printAll(String[] array) { int size= array.length; for(int i=0;i

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

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.

ArrayTools:

public class ArrayTools
{
public static int printAll(String[] array)
{
int size= array.length;
for(int i=0;i<size;i++)
{
System.out.println("["+i+"]: "+array[i]);
}
return size;
}

Demo3 code:

import java.util.Scanner;

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);

  }
}

 

Test Case 1

 
How many strings?\n
8ENTER
Enter a value:\n
aaaaaaENTER
Enter a value:\n
aaaaaENTER
Enter a value:\n
aaaaENTER
Enter a value:\n
aaaENTER
Enter a value:\n
aaENTER
Enter a value:\n
aENTER
Enter a value:\n
aaaaaaaENTER
Enter a value:\n
hello world does this thing Work?ENTER
[0]: AAAAAA <-- Longer than five letters\n
[1]: aaaaa\n
[2]: aaaa\n
[3]: aaa\n
[4]: aa\n
[5]: a\n
[6]: AAAAAAA <-- Longer than five letters\n
[7]: HELLO WORLD DOES THIS THING WORK? <-- Longer than five letters\n
 

Test Case 2

 
How many strings?\n
10ENTER
Enter a value:\n
doltishnessENTER
Enter a value:\n
subclassENTER
Enter a value:\n
carbonizedENTER
Enter a value:\n
myxomaENTER
Enter a value:\n
quiringENTER
Enter a value:\n
confutativeENTER
Enter a value:\n
wealdENTER
Enter a value:\n
unerringlyENTER
Enter a value:\n
unpensioningENTER
Enter a value:\n
indagativeENTER
[0]: DOLTISHNESS <-- Longer than five letters\n
[1]: SUBCLASS <-- Longer than five letters\n
[2]: CARBONIZED <-- Longer than five letters\n
[3]: MYXOMA <-- Longer than five letters\n
[4]: QUIRING <-- Longer than five letters\n
[5]: CONFUTATIVE <-- Longer than five letters\n
[6]: weald\n
[7]: UNERRINGLY <-- Longer than five letters\n
[8]: UNPENSIONING <-- Longer than five letters\n
[9]: INDAGATIVE <-- Longer than five letters\n
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps

Blurred answer
Knowledge Booster
Array
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education