Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Directions Using the supplied starter code on GitHub for each of the following methods: Write test cases to automatically check if your code is correct

Directions

Using the supplied starter code on GitHub for each of the following methods:

Write test cases to automatically check if your code is correct

Write the code for the method

It is very helpful to do things in this order. Writing the test cases helps you understand the problem, which then makes the coding a lot more straightforward.

The methods you need to write are:

Method 1. insertInMiddle -

This accepts two String parameters and returns a new string with s2 inserted in the middle of string s1. For example, insertInMiddle ("abcd", "wxyz") returns "abwxyzcd" If there are an odd number of characters in s1, then split s1 so the middle character comes after s2, so insertInMiddle("abc", "wxyz") returns "awxyzbc"

Method 2. insertTwo -

This accepts two String parameters and returns a new string with the first 2 characters in s2 inserted after every 2 characters in string s1. For example, insertTwo ("abcd", "wxyz") returns "abwxcdwx" If there are an odd number of characters in s1, then just use that one last character, rather than two. For example: insertTwo("abc", "wxyz") returns "abwxcwx"

Method 3. insertInterleaved -

This accepts two String parameters of the same length and returns a new string with the first 2 characters in s1 followed by the first 2 characters of s2, followed by the second 2 characters of s1, followed by the second 2characters of s2, and so on. For example, insertInterleaved ("abcd", "wxyz") returns "abwxcdyz" If there are an odd number of characters in s1 and s2, then just use that one last character, rather than two. For example: insertInterleaved("abc", "xyz") returns "abxycz"

If the strings are not the same length return the empty string.

Notes

You need to specify a message every time you commit your code to a repository. Like comments in the program, these should be meaningful. Saying "Added files" isn't going to tell you anything when you look back. Saying something like "Step 3 completed" is better, but after a week, you won't remember what step 3 was. A better comment would be "Step 3 completed - method to flip a coin".

image text in transcribedI need help with this in all 3 methods in java.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Please help me evaluate this integral. 8 2 2 v - v

Answered: 1 week ago

Question

1.4 Identify tools to help makeevidence-based HRM decisions.

Answered: 1 week ago