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
Burka [1]
3 years ago
9

Write the method makeNames that creates and returns a String array of new names based on the method’s two parameter arrays, arra

y1 and array2. The method creates new names in the following fashion: for each String in array1, concatenate a String from array2. Add a character space between the two strings: array1[i] + " " + array2[j]
In the example below the array names contains 20 names including "David A", "David B", "David C", …, "Lucy E".

String[] first = { "David", "Mike", "Katie", "Lucy"};
String[] middle = {"A", "B", "C", "D", "E");
String[] names = makeNames (first, middle);

If one of the parameter arrays has size 0, return the other parameter array.
In the example below the array names contains 4 names: "David", "Mike", "Katie", "Lucy".

String[] first = {"David", "Mike", "Katie", "Lucy"};
String[] middle = {};
String[] names = makeNames (first, middle);

Use the method header: public static String[] makeNames (String[] array1, String[] array2)

Create a String array containing permutations of strings from two String array parameters.
Computers and Technology
1 answer:
Gwar [14]3 years ago
5 0

Answer:

  1. import java.util.Arrays;
  2. public class Main {
  3.    public static void main(String[] args) {
  4.        String [] first = {"David", "Mike", "Katie", "Lucy"};
  5.        String [] middle = {"A", "B", "C", "D"};
  6.        String [] names = makeNames(first, middle);
  7.        System.out.println(Arrays.toString(names));
  8.    }
  9.    public static String [] makeNames(String [] array1, String [] array2){
  10.           if(array1.length == 0){
  11.               return array1;
  12.           }
  13.           if(array2.length == 0){
  14.               return array2;
  15.           }
  16.           String [] newNames = new String[array1.length];
  17.           for(int i=0; i < array1.length; i++){
  18.               newNames[i] = array1[i] + " " + array2[i];
  19.           }
  20.           return newNames;
  21.    }
  22. }

Explanation:

The solution code is written in Java.

Firstly, create the makeNames method by following the method signature as required by the question (Line 12). Check if any one the input string array is with size 0, return the another string array (Line 14 - 20). Else, create a string array, newNames (Line 22). Use a for loop to repeatedly concatenate the string from array1 with a single space " " and followed with the string from array2 and set it as item of the newNames array (Line 24-26). Lastly, return the newNames array (Line 28).

In the main program create two string array, first and middle, and pass the two arrays to the makeNames methods as arguments (Line 5-6). The returned array is assigned to names array (Line 7). Display the names array to terminal (Line 9) and we shall get the sample output: [David A, Mike B, Katie C, Lucy D]

You might be interested in
Which type of electronic payment is typically favored in b2b?
Dennis_Churaev [7]
Electronic checks would<span> typically be favored in b2b</span>
4 0
2 years ago
Julie: 3: 36, 6:72, 9:108....tell me the next 3 ratios * math*
svlad2 [7]

Answer:

12:144, 15:180,

Explanation:

8 0
3 years ago
Name two commercial tools that can make a forensic sector-by-sector duplicate of a drive to a larger drive.
Temka [501]

Answer:

e34d4e

Explanation:

5 0
3 years ago
What is instance variable??​
azamat

Explanation:

a distance variable includes a value and a dependency. includes a value and a dependency

5 0
3 years ago
Which of the following are examples of transactional information? A. Airline ticket, sales receipts, and packing slips B. Trends
Elenna [48]

Answer: A) Airline ticket, sales receipts, and packing slips

Explanation:

Transactional information is the data that is used for supporting transaction action of every day in a business unit. This information keeps the record whether the transaction is complete or failed.

  • Example - slip of packing,  sale receipt etc.
  • Other options are incorrect because statistic of sales , spreadsheet ,outcome of sale and projection of growth does not relate with transaction process.
  • Thus, the correct option is option(A).

4 0
3 years ago
Other questions:
  • The major difference between a calculator and a computer, when performing calculations, is that a
    10·1 answer
  • Using the C language, write a function that accepts two parameters: a string of characters and a single character. The function
    11·1 answer
  • What is the purpose of a filename extension? How can you restore a file that you deleted from the hard disk?
    10·1 answer
  • Which of the following is not a location where text can be entered​
    15·1 answer
  • In the URL, what is the subdomain and what is the domain name?
    5·1 answer
  • George is sketching a wireframe representation of the home page of his website. What aspect of the home page would be impossible
    11·1 answer
  • What is gained by increasing the ritation speed of a disk or cd?​
    9·1 answer
  • In the context of computer and network security, _____ means that a system must not allow the disclosing of information by anyon
    10·1 answer
  • A maxillary partial denture will have a ____ connector, and the mandibular partial denture will have a ____ connector.
    15·1 answer
  • which server edition doesn't support any server roles that you would typically use with standard version
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!