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
What can you do in the Mouse section of the Devices and Printers menu?
ANTONII [103]
See for yourself.
On windows hit windowskey+r
Type in control and then hit enter
Then search device and printers

The answer is you can add an change settings (dpi, color) of the mouse
3 0
3 years ago
Where is the typical location of a touchpad inside of a laptop?
butalik [34]

Answer:

Attached to the keyboard

Explanation:

Touch pad is the type of the mouse that is located on the laptop just near the keyboard or we can say that it is attached to the keyboard of the laptop. It has almost two buttons that are used for the purpose of Left and Right Click.

The touch pad is used to move the cursor to the required position on the screen of the laptop. This will work by just moving figure on the touch pad as the cursor move on the screen in the same direction of the finger..

5 0
3 years ago
Buying the newest phone as soon as it is released when your current phone works perfectly is not a good idea for all but which o
bixtya [17]

Answer:

You are gonna waste money and it might not be the best idea

Explanation:

5 0
3 years ago
Read 2 more answers
if i set my payment and use free trial on Scribd website, can i cancel my payment and NOT PAYING after one month??
svlad2 [7]
Yes you can, although, this question should have been directed towards the Scribd support team.
6 0
3 years ago
3 ᴍᴜʟᴛɪᴘʟᴇ-ᴄʜᴏɪᴄᴇ Qᴜᴇꜱᴛɪᴏɴꜱ
Damm [24]
4, 1, and 3

The last one I am going to say three because I know that friends show other friends so I wouldn’t call that “private”
6 0
2 years ago
Other questions:
  • Which shortcut key aligns text to the center of a page?
    13·2 answers
  • In a right triangle, the square of the length of one side is equal to the sum of the squares of the lengths of the other two sid
    10·1 answer
  • Convert (35.125)10 to binary
    9·1 answer
  • All linear programming problems have all of the following properties EXCEPT
    9·2 answers
  • Complete the following statement: Sustainability is: Choose all that apply.This task contains the radio buttons and checkboxes f
    10·1 answer
  • In the 1880’s advancements in technology and processes made photography available to the general public. Who is considered the m
    12·1 answer
  • What is computer sences​
    6·1 answer
  • One problem with _______ is that often many copies of the same document are made. <br><br>HELPPP ​
    11·1 answer
  • If any one answered this i will give brilientst what is stimulation program​
    6·1 answer
  • 1.a computer can create an output based on the input of the user.
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!