1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Iteru [2.4K]
2 years ago
15

Write a static method, getBigWords, that gets a single String parameter and returns an array whose elements are the words in the

parameter that contain more than 5 letters. (A word is defined as a contiguous sequence of letters.) EXAMPLE: So, if the String argument passed to the method was "There are 87,000,000 people in Canada", getBigWords would return an array of two elements, "people" and "Canada". ANOTHER EXAMPLE:__deletedc942e16469dfc985bad93686bef33709ea1d39aa11de399983e1c15bed9d613adeleted__", getBigWords would return an array of three elements, "request", "support" and "turingscraft".
Computers and Technology
1 answer:
ZanzabumX [31]2 years ago
7 0

Answer:

import java.util.*;

public class Solution {

   public static void main(String args[]) {

       Scanner scan = new Scanner(System.in);

       System.out.println("Enter the words.");

       String userInput = scan.nextLine();

       

       String[] splitedString = userInput.split(" ");

       getBigWords(splitedString);

       

   }

   

   public static void getBigWords(String[] listOfWord){

       ArrayList<String> list = new ArrayList<String>();

       

       for(int i = 0; i < listOfWord.length; i++){

           if(listOfWord[i].length() > 5){

               list.add(listOfWord[i]);

           }

       }

       

       for (String temp : list) {

  System.out.println(temp);

 }

   }

}

Explanation:

The first line is the import statement which import the classes needed for this class: Scanner and ArrayList.

The class was defined as Solution. Then, the main method is defined. Inside the main method a scanner object is created called scan to receive user input.

The user is prompted for input, which is stored as userInput. The userInput is then splitted and stored in an array called splitedString.

The method that perform the string manipulation is called getBigWords, the method take the splittedString as a parameter.

Next, the getBigWords method is defined; it takes an array as parameter. The parameter is called listOfWord. Inside the getBigWords method, an ArrayList called list is initialized. The list is to hold string whose length is more than 5.

The first for-loop loop through the listOfWord and check if any element has length greater than 5. If there is, the element is added to the list arraylist.

The second for-loop loop through the list to output the words whose length is greater than 5.

You might be interested in
Why do businesses often provide a logo on their web pages?
Nitella [24]
<span>B. They provide viewers with a consistent visual reminder of their company.

This is a prevalent example of branding.</span>
7 0
3 years ago
How to drive more website traffic?
lidiya [134]

Hello there,

How to drive more website traffic?

Answer: Advertise

8 0
3 years ago
How do you use VMware Fusion to make a Tip Calculator?
lana66690 [7]
You have to subtract the tax amount by the final amount then multiply the result by the percentage of tip that is based on the service that you received.
4 0
3 years ago
Which of the following is the language used to create content that is shown on the World Wide Web?
kondor19780726 [428]
Your answer is HTML. 
6 0
2 years ago
Read 2 more answers
HELP!!!<br><br> consider the following two-dimensional array
liq [111]

Answer:

its employment

Explanation:

3 0
2 years ago
Other questions:
  • What OS is most commonly used by businesses? Linux Macintosh Microsoft Windows
    11·1 answer
  • In gaming, "rendering" refers to:
    12·2 answers
  • How do you know if your phone has a virus?
    13·1 answer
  • Given an array arr of type int , along withtwo int variables i and j , write some code thatswaps the values of arr[i] and arr[j]
    6·1 answer
  • How to buy free big money computers that earn free money everydays?
    15·1 answer
  • Write a program that first calls a function to calculate the square roots of all numbers from 1 to 1,000,000 and write them to a
    8·1 answer
  • A seven-octet pattern of alternating 0s and 1s used by the receiver to establish bit synchronization is a _______
    11·1 answer
  • A different way of pronoucing the same words is called a _____
    15·1 answer
  • Location of a video or photoshoot is not important when it comes to preplanning the shoot.
    10·1 answer
  • You would like to see only the last 15 lines of /home/user/log file on your linux machine. Which command line interface (cli) co
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!