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
spayn [35]
3 years ago
14

Write a function listLengthOfAllWords which takes in an array of words (strings), and returns an array of numbers representing t

he length of each word.
Computers and Technology
1 answer:
vesna_86 [32]3 years ago
7 0

Answer:

   public static int[] listLengthOfAllWords(String [] wordArray){

       int[] intArray = new int[wordArray.length];

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

           int lenOfWord = wordArray[i].length();

           intArray[i]=lenOfWord;

       }

       return intArray;

   }

Explanation:

  1. Declare the method to return an array of ints and accept an array of string as a parameter
  2. within the method declare an array of integers with same length as the string array received as a parameter.
  3. Iterate using for loop over the array of string and extract the length of each word using this statement  int lenOfWord = wordArray[i].length();
  4. Assign the length of each word in the String array to the new Integer array with this statement intArray[i]=lenOfWord;
  5. Return the Integer Array

A Complete Java program with a call to the method is given below

<em>import java.util.Arrays;</em>

<em>import java.util.Scanner;</em>

<em>public class ANot {</em>

<em>    public static void main(String[] args) {</em>

<em>       String []wordArray = {"John", "James", "David", "Peter", "Davidson"};</em>

<em>        System.out.println(Arrays.toString(listLengthOfAllWords(wordArray)));</em>

<em>        }</em>

<em>    public static int[] listLengthOfAllWords(String [] wordArray){</em>

<em>        int[] intArray = new int[wordArray.length];</em>

<em>        for (int i=0; i<wordArray.length; i++){</em>

<em>            int lenOfWord = wordArray[i].length();</em>

<em>            intArray[i]=lenOfWord;</em>

<em>        }</em>

<em>        return intArray;</em>

<em>    }</em>

<em>}</em>

This program gives the following array as output: [4, 5, 5, 5, 8]

You might be interested in
At one time, a station sign-off test pattern was designed so TV owners could adjust the quality of their picture and sound
mamaluj [8]

Answer:

true

Explanation:

7 0
3 years ago
Contemporary operation of networking technology is possible only through the usage of open-use technology and layering approache
eimsori [14]

Answer: TRUE

Explanation: Networking technology is the term used to describe the entire processes through which computer or mobile systems are linked up either through optic fibers,wireless systems in order to enhance effective communication across networks or regions.

OSI (open system interconnection), the earliest models partitions into seven layers and the OSI is known as model that creates partitioning a communication system classing them into abstraction layers.

8 0
3 years ago
Please help!!
Margarita [4]

Answer:

<h2>Server</h2>

Explanation:

<h3>i hope its help you</h3>
6 0
3 years ago
Which solution eliminates the need for dedicated high-speed WAN connections between sites
s344n2d4d5 [400]

Answer:

running in the 90 s intensifies

Explanation:

4 0
3 years ago
In a server farm such as that used by Amazon or eBay, a single failure does not cause the entire system to crash. Instead, it wi
Jet001 [13]

Answer:12 days

Explanation:

Mean time to failure is given by

MTTF=\frac{Total working hours of running}{Total no. of units}

Let's say N is the average amount  of time system runs until \frac{1}{3} computer fail

MTTF of each computer =35

35=\frac{n\cdot 10,000}{10,000\cdot \frac{1}{3}}

35=N\cdot 3

N=\frac{35}{3}=11.667\approx 12days

8 0
3 years ago
Other questions:
  • 6. When should you return to the right lane after passing another car on the left?
    14·2 answers
  • _______ _____ is the process of creating usable computer pograms and applications and the theories behind those processes. Quest
    13·2 answers
  • On the Loan worksheet, in cell C9, enter a PMT function to calculate the monthly payment for the Altamonte Springs 2018 faciliti
    6·1 answer
  • To reload a picture taken with a digital camera means to copy the digital picture from the camera to your computer.
    5·2 answers
  • Which wireless communication is typically limited to six feet of distance?
    14·1 answer
  • What is the multiple source test
    15·1 answer
  • When I click on someone who asked a question and i want to see there answer it is always blurred and when I asked a question I c
    8·1 answer
  • Write a Java code statement for each of following:
    6·1 answer
  • Which of the following does a code editor NOT provide?
    12·1 answer
  • The designers of a database typically begin by developing a​ __________ to construct a logical representation of the database be
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!