Question: Please help me with question 1 (b). This is a Java coding question. Thank you. Directions: SHOW ALL YOUR WORK. REMEMBER THAT PROGRAM SEGMENTS ARE

Please help me with question 1 (b). This is a Java coding question. Thank you.

Please help me with question 1 (b). This is a Java codingquestion. Thank you. Directions: SHOW ALL YOUR WORK. REMEMBER THAT PROGRAM SEGMENTSARE TO BE WRITTEN IN JAVA. Notes: Assume that the classes listed

Directions: SHOW ALL YOUR WORK. REMEMBER THAT PROGRAM SEGMENTS ARE TO BE WRITTEN IN JAVA. Notes: Assume that the classes listed in the Java Quick Reference have been imported where appropriate. Unless otherwise noted in the question, assume that parameters in method calls are not null and that methods are called only when their preconditions are satisfied. In writing solutions for each question, you may use any of the accessible methods that are listed in classes defined in that question. Writing significant amounts of code that can be replaced by a call to one of these methods will not receive full credit. 1. Consider the following partial declaration for a WordScrambler class. The constructor for the WordScrambler class takes an even-length array of String objects and initializes the instance variable scrambledWords. public class WordScrambler { private String[] scrambledwords; * /** @param wordArr an array of String objects Precondition: wordArr.length is even */ public Wordscrambler (String[] wordArr) { scrambledWords = mixedWords (wordArr); } * /** @param wordi a String of characters @param word2 a String characters @return a String that contains the first half of word1 and the second half of word2 */ private String recombine(String wordi, String word2) { /* to be implemented in part (a) */ } * /** @param words an array of String objects Precondition: words.length is even @return an array of String objects created by recombining pairs of strings in array words Postcondition: the length of the returned array is words.length */ private String[] mixedWords (String[] words) { /* to be implemented in part (b) */ } * 1/ There may be instance variables, constructors, and methods that are not shown. } (b) Write the WordScrambler method mixedwords. This method creates and returns a new array of String objects as follows. It takes the first pair of strings in words and combines them to produce a pair of strings to be included in the array returned by the method. If this pair of strings consists of wl and w2, the method should include the result of calling recombine with wl and w2 as arguments and should also include the result of calling recombine with w2 and wl as arguments. The next two strings, if they exist, would form the next pair to be processed by this method. The method should continue until all the strings in words have been processed in this way and the new array has been filled. For example, if the array words contains the following elements: {"apple", "pear", "this", "cat"} then the call mixedWords (words) should return the following array. {"apar", "peple", "that", "cis" } In writing mixedWords, you may call recombine. Assume that recombine works as specified, regardless of what you wrote in part (a). Complete method mixedWords below. * * /** @param words an array of String objects Precondition: words.length is even @return an array of String objects created by recombining pairs of strings in array words Postcondition: the length of the returned array is words.length */ private String[] mixedWords (String[] words) *

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!