Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Method transform2 (13 points) Create a public static method transform 2 that has one parameter array of type String[] and returns a String. It should
Method transform2 (13 points) Create a public static method transform 2 that has one parameter array of type String[] and returns a String. It should create and return a new string based on the array that is provided as an argument. The specifications are described below. Use appropriate methods from class String and/or StringBuilder to implement the method transform2. Here are the specifications: 1. To create the new string, add all array elements in the order in which they are stored in the array (first to last). (4 out of 13 points) 2. Every time an array element is added, it should be followed by a front slash (/) (see example) (3 out of 13 points) 3. If the length of the array is 5 or less, add the length of the array at the beginning of the new string (see example). (4 out of 13 points) Otherwise, add ' ' at the beginning of the string. 4. If the user passes an empty array as an argument, an empty string should be returned ( 2 out of 13 points) Examples: ["a", "bb", "ccc"] .. describes an array that includes 3 strings: "a", "bb", and "ccc" Note that this is pseudo code. The method call transform2(["hi"]) ; won't compile. transform2(["hi"]) returns "1hi/" transform2(["one", "two", "three"]) returns "3one/two/three/" transform2([]) returns "'" transform2(["5", "4", "3", "2", "1"]) returns "55/4/3/2/1/" transform2(["a", "b", "c", "d", "e", "f"]) returns "^a/b/c/d/e/f/
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