Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

to be done in JAVA requirements: * - It is strictly forbidden for you to use: * + Any Java library class (e.g., ArrayList, Arrays)

image text in transcribedto be done in JAVA

requirements: * - It is strictly forbidden for you to use: * + Any Java library class (e.g., ArrayList, Arrays) * (That is, there must not be an import statement in the beginning of this class.)

/* * Input Parameters: * - `sa`: an array of strings * * Assumptions: * - Input array `sa` is non-empty and contains at least one elements. * The string value that appears the most frequently is unique. * * What to return? * - Return the string value that appears the most frequently, * i.e., appear for the highest number of times. * * See the JUnit tests related to this method. */ public static String task4(String[] sa) { String result = null; /* Your task is to implement this method, * so that running TestUtilities.java will pass all JUnit tests. * * 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. No Scanner operations should appear here (e.g., input.nextInt()). * Instead, refer to the input parameters of this method. * 3. Do not re-assign any of the parameter/input variables. */

/* * Tests related to Task 4 */ @Test public void test_task4_1() { String[] seq = {"a"}; String expected = "a"; assertEquals(expected, Utilities.task4(seq)); } @Test public void test_task4_2() { String[] seq = {"a", "a", "a"}; String expected = "a"; assertEquals(expected, Utilities.task4(seq)); } @Test public void test_task4_3() { String[] seq = {"b", "a", "c", "d", "a"}; String expected = "a"; assertEquals(expected, Utilities.task4(seq)); }

to pass all these tests

* Input Parameters: 'sa: an array of strings Assumptions: Input array 'sa' is non-empty and contains at least one elements. " The string value that appears the most frequently is unique. * What to return? - Return the string value that appears the most frequently, i.e., appear for the highest number of times. See the JUnit tests related to this method. 1630 164 165 166 167 168 169 170 171 172 173 174 175 176 1770 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 } public static String task4(String[] sa) { String result = null; 1* Your task is to implement this method, * so that running TestUtilities.java will pass all JUnit tests. * * 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. No Scanner operations should appear here (e.g., input.nextInt(). Instead, refer to the input parameters of this method. 3. Do not re-assign any of the parameter/input variables. */ // Your implementation of this method starts here. // Do not modify this return statement. return result; }

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

Step: 3

blur-text-image

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

Information Modeling And Relational Databases

Authors: Terry Halpin, Tony Morgan

2nd Edition

0123735688, 978-0123735683

More Books

Students also viewed these Databases questions