Menu

[Solved]Class Functions2 Demonstrate Ability Code Specific Requirements Exercise Involves Implemen Q37248161

/** Class Functions2 is to demonstrate the ability to code to specific requirements. <br> <br> This exercise involves implementing several methods. Stubs for each method with documentation are given here. It is your task to fill out the code in each method body so that it runs correctly according to the documentation. <br> <br> You should create a main method to run and test your methods. Example inputs with output are provided in the comments before each method. At a minimum, your solutions must pass these tests. //import NOTICE: Imports are not allowed for this assignments!*/public class Functions2{ /** Given two ints, return an int array containing the ints in value order. <br> <br> array2Ints(7, 3) -> {3, 7} <br> array2Ints(7, 7) -> {7, 7} <br> array2Ints(3, 7) -> {3, 7} <br> array2Ints(3, -4) -> {-4, 3} <br> @param firstNumber int an integer. @param secondNumber int an integer. @return int[] An array of the two integers as elements. **/ public static int[] array2Ints(int firstNumber, int secondNumber) { //your code here return new int[1]; }//end array2Ints /** Given two Strings return a String array containing the strings in alphabetical order. <br> Note: Capital letters count <br> <br> array2Strings(“washington”, “irving”) -> {“irving”, “washington”} <br> array2Strings(“washington”, “Irving”) -> {“Irving”, “washington”} <br> array2Strings(“Washington”, “irving”) -> {“Washington”, “irving”} <br> array2Strings(“washington”, “Washington”) -> {“Washington”, “washington”} <br> @param firstString a String. @param secondString a String. @return String[] An array of the two Strings as elements. **/ public static String[] array2Strings(String firstString, String secondString) { //your code here return new String[1]; }//end array2Strings /** Given an int and an array of two ints, return an array of 3 ints sorted in value order. <br> <br> sort3Ints(5, {3, 7}) -> {3, 5, 7} <br> sort3Ints(7, {5, 3}) -> {3, 5, 7} <br> sort3Ints(3, {3, 3}) -> {3, 3, 3} <br> sort3Ints(3, {3, -4}) -> {-4, 3, 3} <br> @param intValue int an integer. @param intArray int[] an array of integers. @return int[] An array of the three integers sorted as elements. **/ public static int[] sort3Ints(int intValue, int[] intArray) { //your code here return new int[1]; }//end sort3Ints /** Given a String and an array of two Strings, return a three String array containing the strings in alphabetical order. <br> Note: Capital letters count. <br> <br> sort3Strings(“wallace”, {“washington”, “irving”}) -> {“irving”, “wallace”, “washington”} <br> sort3Strings(“wallace”, {“washington”, “Irving”}) -> {“Irving”, “wallace”, “washington”} <br> sort3Strings(“Washington”, {“irving”, wallace”}) -> {“Washington”, “irving”, “wallace”} <br> sort3Strings(“washington”, {“washington”, “Washington”}) -> {“Washington”, “washington”, “washington”} <br> @param stringValue String a String. @param stringArray String[] an array of Strings. @return String[] An array of the three Strings sorted as elements. **/ public static String[] sort3Strings(String stringValue, String[] stringArray) { //your code here return new String[1]; }//end sort3Strings /** Given two int arrays of length two, return a length four int array containing the ints in value order. <br> Hint: use your array2Ints method. <br> <br> merge2Ints({3, 4}, {1, 2}) -> {1, 2, 3, 4} <br> merge2Ints({1, 2}, {3, 4}) -> {1, 2, 3, 4} <br> merge2Ints({7, 7}, {7, 7}) -> {7, 7, 7, 7} <br> @param firstNumbers int[] an array of integers. @param secondNumbers int[] an array of integers. @return int[] An array of the four integers sorted as elements. **/ public static int[] merge2Ints(int[] firstNumbers, int[] secondNumbers) { int[] returnValue = new int[2]; //your code here return returnValue; }//end merge2Ints /** Given two Strings return a String array containing the strings in alphabetical order. <br> Note: Capital letters count. <br> Hint: use your array2Strings method. <br> <br> merge2Strings({“a”, “b”}, {“c”, “d”}) -> {“a”, “b”, “c”, “d”} <br> merge2Strings({“a”, “b”}, {“c”, “D”}) -> {“D”, “a”, “b”, “c”} <br> merge2Strings({“d”, “c”}, {“b”, “a”}) -> {“a”, “b”, “c”, “d”} <br> merge2Strings({“My”, “Dear”}, {“Aunt”, “Sally”}) -> {“Aunt”, “Dear”, “My”, “Sally”} <br> merge2Strings({“my”, “dear”}, {“Aunt”, “Sally”}) -> {“Aunt”, “Sally”, “dear”, “my”} <br> merge2Strings({“Irving”, “washington”}, {“Irving”, “berlin”}) -> {“Irving”, “Irving”, “berlin”, “washington”} <br> @param firstStrings String[] an array of Strings. @param secondStrings String[] an array of Strings. @return String[] An array of the four Strings sorted as elements. **/ public static String[] merge2Strings(String[] firstStrings, String[] secondStrings) { //your code here return new String[1]; }//end merge2Strings /** Given an int array, return true if the array contains duplicate values. <br> <br> duplicateInts({3}) -> false <br> duplicateInts({1, 2}) -> false <br> duplicateInts({7, 7}) -> true <br> duplicateInts({1, 2, 3, 4, 5}) -> false <br> duplicateInts({1, 2, 3, 2, 4, 5}) -> true <br> @param numbers int[] an array of integers. @return boolean Return True if the array contains dublicates. **/ public static boolean duplicateInts(int[] numbers) { //your code here return false; }//end duplicateInts /** Given a String array, return true if the array contains duplicate values. <br> Note: Capital letters count <br> duplicateStrings({“a”}) -> false <br> duplicateStrings({“a”, “b”, “c”, “d”}) -> false <br> duplicateStrings({“a”, “a”}) -> true <br> duplicateStrings({“A”, “a”}) -> false <br> duplicateStrings({“these”, “are”, “the”, “times”}) -> false <br> duplicateStrings({“these”, “are”, “the”, “times”, “they”, “are”}) -> true <br> duplicateStrings({“my”, “dear”}, {“Aunt”, “Sally”}) -> {“Aunt”, “Sally”, “dear”, “my”} <br> duplicateStrings({“Irving”, “washington”}, {“Irving”, “berlin”}) -> {“Irving”, “Irving”, “berlin”, “washington”} <br> @param strings String[] an array of Strings. @return boolean Return True if the array contains dublicates. **/ public static boolean duplicateStrings(String[] strings) { //your code here return false; }//end duplicateStrings /** Given an int array, return an int array with duplicate ints removed if the array contains duplicate values. <br> <br> removeDuplicateInts({3}) -> {3} <br> removeDuplicateInts({1, 2}) -> {1, 2} <br> removeDuplicateInts({7, 7}) -> {7} <br> removeDuplicateInts({1, 7, 1, 7, 1}) -> {1, 7} <br> removeDuplicateInts({1, 2, 3, 4, 5}) -> {1, 2, 3, 4, 5}) <br> removeDuplicateInts({1, 2, 3, 2, 4, 2, 5, 2}) -> {1, 2, 3, 4, 5} <br> @param numbers int[] an array of integers. @return int[] An array with the duplicates removed. **/ public static int[] removeDuplicateInts(int[] numbers) { //your code here return numbers; } // end removeDuplicateInts /** Given a String array, return an String array with duplicate Strings removed if the array contains duplicate values. <br> Note: Capital letters count. <br> <br> removeDuplicateStrings({“a”}) -> {“a”} <br> removeDuplicateStrings({“a”, “b”, “c”, “d”}) -> {“a”, “b”, “c”, “d”} <br> removeDuplicateStrings({“a”, “a”}) -> {“a”} <br> removeDuplicateStrings({“A”, “a”}) -> {“A”, “a”} <br> removeDuplicateStrings({“these”, “are”, “the”, “times”}) -> {“these”, “are”, “the”, “times”} <br> removeDuplicateStrings({“these”, “times”, “are”, “the”, “times”, “they”, “are”}) -> {“these”, “times”, “are”, “the”, “they”} <br> @param strings String[] an array of integers. @return String[] An array with the duplicates removed. **/ public static String[] removeDuplicateStrings(String[] strings) { //your code here return strings; }//end removeDuplicateStrings /** Given two int arrays return true if the arrays contain the same values in the same order. <br> Note: Order matters, see the third example. <br> <br> compare2IntArrays({3, 4}, {1}) -> false <br> compare2IntArrays({1, 2}, {1, 2}) -> true <br> compare2IntArrays({1, 2}, {2, 1}) -> false <br> compare2IntArrays({1, 2, 3, 4}, {1, 2, 3, 4}) -> true <br> @param firstNumbers int[] an array of Integers. @param secondNumbers int[] an array of Integers. @return boolean Return True if the array contains the same elements in the same order. **/ public static boolean compare2IntArrays(int[] firstNumbers, int[] secondNumbers) { //your code here return false; }//end compare2IntArrays /** Given two String arrays return true if the arrays contain the same values in the same order. <br> Note: Order matters, see the forth example. <br> Note: Capatil letters matter, see the final example. <br> <br> compare2StringArrays({“and”}, {“or”}) -> false <br> compare2StringArrays({“and”, “but”}, {“or”}) -> false <br> compare2StringArrays({“a”, “b”, “c”, “d”}, {“a”, “b”, “c”, “d”}) -> true <br> compare2StringArrays({“a”, “b”, “c”, “d”}, {“d”, “c”, “b”, “d”}) -> false <br> compare2StringArrays({“a”, “b”, “c”, “d”}, {“A”, “b”, “C”, “d”}) -> false <br> compare2StringArrays({“Aunt”, “Sally”}, {“Aunt”, “Sally”}) -> true <br> compare2StringArrays({“Aunt”, “Sally”}, {“Aunt”, “sally”}) -> false <br> @param firstStrings Strings[] an array of Strings. @param secondStrings String[] an array of Strings. @return boolean Return True if the array contains the same elements in the same order. **/ public static boolean compare2StringArrays(String[] firstStrings, String[] secondStrings) { //your code here return false; }//end TESTcompare2StringArrays}//end Functions2

Expert Answer


Answer to /** Class Functions2 is to demonstrate the ability to code to specific requirements. This exercise involves implementin… . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *