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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started