Question: IN JAVA. DO NOT IMPORT ANY ARRAY OR MATH LIBRARIES. Please use a separate method and not the main method as mentioned below in the

IN JAVA. DO NOT IMPORT ANY ARRAY OR MATH LIBRARIES. Please use a separate method and not the main method as mentioned below in the todo section. Please do not use any array lists and only use arrays, for/while loops, and if statements.

IN JAVA. DO NOT IMPORT ANY ARRAY OR MATH LIBRARIES. Please use

UTILITY FILE:

a separate method and not the main method as mentioned below in

THE CONSOLE APP CODE FOR TESTING:

the todo section. Please do not use any array lists and only

Problem. You are asked to implement a utility method which takes as input an array of integers and returns another array of strings, each of which denoting a non-empty prefix of the input array. For example, if the input array is: Then the output or returned array of string values is: Note that the length of the output array is equal to the length of the input array. Also, elements in the output array are sorted by the lengths of the prefixes (eg, the first element is the prefix of length 1, the second element is the prefix of length 2). Testing. Your goal is to first pass all tests related to this method in the JUnit test class TestUtilities. You are encouraged to write additional JUnit tests. These tests document the expected values on various cases: study them while developing your code. However, use the console application class GetAllPrefixesApp if you wish (e.g., use the input and expected values from the JUnit tests). Here is an example run: How many numbers do you want to input? 5 Enter input 1: 3 Enter input 2: 1 Enter input 3: 4 Enter input 4: 2. Enter input 5: 5 Todo. Implement the Utilities.getAllPrefixes method. See the comments there for the input parameters and requirements. 98 99 100 1010 102 103 104 105 106 107 108 /* * Input parameters: "numbers : an array of integers * * * Assumptions: - numbers. length >= 1 * * 109 * Refer to you lab instructions for what the method should return. */ public static String[] getAllPrefixes(int[] numbers) { String[] result = null; /* Your implementation of this method starts here. * Recall from Week 1's tutorial videos: * 1. No System.out.println statements should appear here. Instead, an explicit, final return statement is placed for you. * 2. anner operations should appear here (e.g., input.nextInt()). * Instead, refer to the input parameters of this method. */ 1106 111 112 113 114 115 116 11 118 119 120 121 122 123 124 125 126 127 128 129 130 /* Your implementation ends here. */ return result; } 18 i ++; 1 package console_apps; 2 30 import java.util.Scanner;. 6 7 public class GetAllPrefixesApp { 8 ge public static void main(String[] args) { 10 Scanner input = new Scanner(System.in); 11 12 /* Prompt the user for an array of numbers. */ 13 System.out.println("How many numbers do you want to input?"); 14 int howMany = input.nextInt(); 15 int[] numbers = new int[howMany]; 16 int i = 0; 17 while(i "); 36 37 input.close(); 38 } 39 40 } 41 27 33

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!