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
A5.3 1012 kg satellite is 1,800 m from another satellite that has a mass of 3.5 x 108 kg. What is the gravitational
SIZIF [17.4K]

Answer:

F = 3.82 * 10^4N

Explanation:

Given

Mass of satellite 1 = 5.3 * 10¹²kg

Mass of satellite 2 = 3.5 * 10⁸kg

Distance between them = 1,800 m

Required

Gravitational Force between them.

The gravitational force between them is calculated as thus;

F = \frac{Gm_1m_2}{r^2}

Where G = Gravitational Constant

G = 6.67408 * 10^{-11} Nm^2/kg^2

m_1 = 5.3 * 10^{12}kg

m_2 = 3.5 * 10^8kg

r = 1800m

Substituting these values in the above formula;

F = \frac{Gm_1m_2}{r^2} becomes

F = \frac{6.67408 * 10^{-11} * 5.3 * 10^{12}*3.5 * 10^8}{1800^2}

F = \frac{6.67408 * 5.3 * 3.5 * 10^{-11} * 10^{12} * 10^8}{1800^2}

F = \frac{123.804184 * 10^{9}}{3240000}

F = \frac{123804184000}{3240000}

F = 38211.1679012

F = 3.82 * 10^4N ---- Approximated

Hence the gravitational force between them is 3.82 * 10^4N

4 0
4 years ago
Why is simplicity important in navigation design?
riadik2000 [5.3K]
I think it’s B.
Since it’s sometime easier to visually see something.
3 0
3 years ago
The term ________ refers to fluid flow back to the pan to empty or drain a circuit.
Strike441 [17]

The term is: transmission flush

8 0
3 years ago
Explain the basic method for implementing paging.
iogann1982 [59]

Answer:

The answer is below

Explanation:

In order to carry out the basic method for implementing paging, the following processes are involved:

1. Both physical and logical memories are broken into predetermined sizes of blocks otherwise known as FRAMES and PAGES respectively

2. During processing, Pages are loaded into the accessible free memory frames from the backing store. The backing store is however compartmentalized into predetermined sizes of blocks whose size is equal to the size of the memory frames

8 0
3 years ago
Debugging is not testing, but always occurs as a consequence of testing. <br> A) TRUE<br> B) FALSE
kherson [118]
A) True Hope that helps
5 0
4 years ago
Other questions:
  • Which markup language would be considered the most current for web design? HTLM, HTML5, XHTLM, XHTML 6
    14·2 answers
  • In what year did commercial use of the Internet become available? 1991 1996 1999 2001
    9·1 answer
  • Fundamental types of data, such as strings, integers, and real numbers, are known as
    5·1 answer
  • The ____ command displays the last 10 lines of a text file.
    5·1 answer
  • Which button, when pressed, allows light from the subject to fall on the sensor?
    8·1 answer
  • Which of the following is not a metamorphic agent?
    8·2 answers
  • 16. Which of the following wire gage sizes is the thickest? A. 14 B. 8 C. 0 D. -33
    14·1 answer
  • What is the purpose of a primary key?
    5·1 answer
  • Kylee needs to ensure that if a particular client sends her an email while she is on vacation, the email is forwarded to a
    5·1 answer
  • JAVA NEED HELP ASAP
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!