Question: Exercise 7 ( Braiding ) In this assignment, we wil create two methods. ( a ) Create the methed public static String mergesString 8 ,
Exercise Braiding
In this assignment, we wil create two methods.
a Create the methed public static String mergesString String it The method must "merge" lwo
strings s and so that the reshit is a string where every other character comes from and every
other character comes from t it a and thave different lengths, what is "eftover" must be added in
the back.
The method should retum the concatenatod string. The following examples show areas of use.
String a mergoABC "DEF"l W a is now
"ADBECF" a
mergeJKLMN"OPCF; f a is now
TOJPKOLMMN' a mergeC
AB;; a is now AB
Empty strings are legal input.
b Creste the method public static String mergeString The method must "merge" together all the
strings in the table The merging must successively retrieve the first character from the firgt
string, then the first character from the second atring, and then
Machine Translated by Google
further. After the last string we start again with now other characters from the first
string, then other characters from the second string, and so on An "exhausted"
string must be skipped. The concatenated string should be returned. The following
example shows the area of use.
String a mergeAM L "GEDS", "ORATKRR",
R TRTE", "TGAUU"; a is
now "ALGORITHMS AND DATA STRUCTURES"
It should not give an error message to submit zero strings but the response should
then be an empty string or one string but the response should then be the same string
Hint: By using a double for loop, you can almost loop through siDj where i corresponds
to which "word" you're on and j is which "letter" you've reached. But note that we will go
through "slower" than i
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
