Question: Write a program that has a method called interweave. This method takes in two Strings and returns a new String that has interweaved the letters
Write a program that has a method called interweave. This method takes in two Strings and returns a new String that has interweaved the letters (the letter of the first String goes first). If one of the Strings is longer than the other, then just add the remaining letters to the end of the new String.
Note: for this method, you can only use the following String class methods: length and charAt.
Method Header:
public static String interweave (String str1, String str2)
You will test your method in the main method of your program by using a Scanner that will read in two Strings. The Strings will be space-separated, so you dont need to worry about interweaving phrases or sentences.
Then call the method and pass the two Strings into the method and print the new String.
Input
Two words as strings. Sample Input: Halifax Dartmouth
Output
The two strings interweaved together. Sample Output: HDaalritfmaoxuth
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
