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
Anna discovers malware on her computer. After being downloaded, the malware self-activated and replicated itself and infected th
Tresset [83]

Answer:

A.

Explanation:

The malware that replicates itself and can infect the entire system is a worm.

A worm is a type of malware that gets self-activated and replicated. This worm spreads rapidly over the computer system and can corrupt all the files and the entire system.

A worm is a standalone application and does not require action from humans.

Therefore, option A is correct.

6 0
3 years ago
Which statement about the router configurations is correct?
Alika [10]

Answer:

<em>Answer : D</em>

Explanation:

When we check Branch3 router according to the attached diagram we notice that “network 192.168.10.0” command is missing under “router eigrp 100” .

Branch 3# Show running-config according to the attached diagram

<output ommited>

!

router eigrp 100

network 192.168.16.0

6 0
3 years ago
May someone do this please? Thanks!!
vovangra [49]

Answer:Jeez

Explanation: thats a lot

5 0
3 years ago
Assume that a finite number of resources of a single resource type must be managed. Processes may ask for a number of these reso
nevsk [136]
The answer may not be found
5 0
3 years ago
For each of the descriptions below, perform the following tasks:
zlopas [31]

Answer:

Explanation:

The underlined traits in the ER chart speak to essential key since they remarkably recognize the quality  

(a)

(I) The level of the given relationship is 2 i.e it is a parallel connection among Book and Publisher. It is a one to numerous relationship from distributer to book in light of the fact that a distributer can distribute any number of books however a book will have only one publisher,so the cardinality will be 1 to 1..* (one to many)

(b)

(i) The degree of the given relationship is 2 i.e it is a binary relationship between Author and Book. It is a many to many relationship from Book to Author a book can be written by one or more authors and an author can write more than one book, so the cardinality will be 1..* to 1..* (many to many)

(c)

(i) As mentioned in part (b), the degree of given relation is 2 and cardinality is many to many (1..* to 1..*)

(d)

(i) The degree of the given relationship is 1 i.e unary relationship. It is a many to many relationship because one book can belong to any sets and a set can have any number of books, so cardinality is 1..* to 1..* (many to many)

Note: attached below is the image of various options to confirm the explanation (answer).

cheers i hope this helped !!!

4 0
4 years ago
Other questions:
  • Suppose you are using a Mac to read your e-mail messages, and you receive an
    8·2 answers
  • What should you change if you want one particular slide to have a different arrangement of text box placeholders?
    10·1 answer
  • A(n) _____ might be written by a programmer or it might be created through a DBMS utility program.
    6·1 answer
  • Which of the following is a beneficial reason to extract mineral resources from the earth?
    13·2 answers
  • Two technicians are discussing shielded cable. Technician A says that shielded wires are generally twisted in pairs to cancel th
    14·1 answer
  • Create a class called Fraction. Provide a constructor that takes 2 integers. Provide methods for:
    8·1 answer
  • Nonprogrammed decision
    7·1 answer
  • Why is computer called information processing maching???​
    6·2 answers
  • How can we work together to fix problems with our websites
    9·1 answer
  • 2 examples of free, proprietary and online software for multimedia presentations (two of each) ._.
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!