/**
Given a String and an array of two Strings,
return a three String array containing the strings in
alphabetical order.
Note: Capital letters count
sort3Strings("wallace", {"washington", "irving"})
-> {"irving", "wallace", "washington"}
sort3Strings("wallace", {"washington", "Irving"})
-> {"Irving", "wallace", "washington"}
sort3Strings("Washington", {"irving", wallace"}) ->
{"Washington", "irving", "wallace"}
sort3Strings("washington", {"washington",
"Washington"}) -> {"Washington", "washington",
"washington"}
**/
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.
Hint: use your array2Ints
method
merge2Ints({3, 4}, {1, 2}) ->
{1, 2, 3, 4}
merge2Ints({1, 2}, {3, 4}) ->
{1, 2, 3, 4}
merge2Ints({7, 7}, {7, 7}) ->
{7, 7, 7, 7}
**/
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.
Note: Capital letters count
Hint: use your array2Strings
method
merge2Strings({"a", "b"}, {"c",
"d"}) -> {"a", "b", "c", "d"}
merge2Strings({"a", "b"}, {"c",
"D"}) -> {"D", "a", "b", "c"}
merge2Strings({"d", "c"}, {"b",
"a"}) -> {"a", "b", "c", "d"}
merge2Strings({"My", "Dear"},
{"Aunt", "Sally"}) -> {"Aunt", "Dear", "My", "Sally"}
merge2Strings({"my", "dear"},
{"Aunt", "Sally"}) -> {"Aunt", "Sally", "dear", "my"}
merge2Strings({"Irving",
"washington"}, {"Irving", "berlin"}) -> {"Irving", "Irving",
"berlin", "washington"}
**/
public static String[] merge2Strings(String[]
firstStrings, String[] secondStrings) {
//your code here
return new String[1];
}//end merge2Strings
===============================================================================================================================================================================
Please do not use sort() or arrayList methodsto solve this problesms ...
we are not allow to use them....
just simple coding.
thanks
===============================================================================================================================================================================
import java.util.Arrays;
// A Class that uses above Custom
public class Main {
// 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
int low = Math.min(Math.min(intArray[0], intArray[1]), intValue);
int high = Math.max(Math.max(intArray[0], intArray[1]), intValue);
return new int[] { low, intArray[0] + intArray[1] + intValue - low - high, high };
}// 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
String arr[] = new String[3];
arr[0] = stringValue;
arr[1] = stringArray[0];
arr[2] = stringArray[1];
for (int i = 0; i < arr.length; i++) {
for (int j = i + 1; j < arr.length; j++) {
if (arr[i].compareTo(arr[j]) > 0) {
String temp = arr[i];
arr[i] = arr[j];
arr[j] = temp;
}
}
}
return arr;
}// 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[firstNumbers.length + secondNumbers.length];
int i = 0, j = 0, k = 0;
while (i < firstNumbers.length)
returnValue[k++] = firstNumbers[i++];
while (j < secondNumbers.length)
returnValue[k++] = secondNumbers[j++];
for ( i = 0; i < returnValue.length; i++) {
for (j = i + 1; j < returnValue.length; j++) {
if (returnValue[i] > returnValue[j]) {
int temp = returnValue[i];
returnValue[i] = returnValue[j];
returnValue[j] = temp;
}
}
}
// 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) {
String [] returnValue = new String[firstStrings.length + secondStrings.length];
int i = 0, j = 0, k = 0;
while (i < firstStrings.length)
returnValue[k++] = firstStrings[i++];
while (j < secondStrings.length)
returnValue[k++] = secondStrings[j++];
for ( i = 0; i < returnValue.length; i++) {
for (j = i + 1; j < returnValue.length; j++) {
if (returnValue[i].compareTo(returnValue[j]) > 0) {
String temp = returnValue[i];
returnValue[i] = returnValue[j];
returnValue[j] = temp;
}
}
}
// your code here
return returnValue;
}// end merge2Strings
public static void main(String args[]) {
System.out.println(Arrays.toString(sort3Strings("wallace", new String[]{"washington", "irving"}) ));
System.out.println(Arrays.toString(merge2Strings(new String[]{"d", "c"}, new String[]{"b", "a"}) ));
System.out.println(Arrays.toString(merge2Ints(new int[]{3, 4}, new int[]{1, 2}) ));
}
}
===============================================
SEE OUTPUT

PLEASE COMMENT if there is any concern.
==============================
/** Given a String and an array of two Strings, return a three String...
/** Given an int array, return true if the array contains duplicate values. duplicateInts({3}) -> false duplicateInts({1, 2}) -> false duplicateInts({7, 7}) -> true duplicateInts({1, 2, 3, 4, 5}) -> false duplicateInts({1, 2, 3, 2, 4, 5}) -> true **/ 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. Note: Capital letters count duplicateStrings({"a"}) -> false duplicateStrings({"a", "b", "c", "d"}) -> false duplicateStrings({"a",...
Hey, I was wondering if there’s another way to make these methods not reliable to imports such as “import java.util.Arrays” and “import java.util.Hash” I am still new in coding and would like to know if there’s another way to do it! Here is the code! (Thank you in advance and I will really appreciate it :) ) /** This exercise involves implementing several methods. Stubs for each method with documentation are given here. It is your task to fill out...
DESCRIPTION: You will be given a 1-D array, called wordFun, of Strings. The array has an unknown number of cells filled with data. As before, the array will already be filled with strings, some of which contain the string "Angela". You will create a method called countItUp which returns and integer array containing the number of times each of the letters in my name occur within the strings within this array. For example, if the input array was wordFun =...
DESCRIPTION: You will be given a 1-D array, called wordFun, of Strings. The array has an unknown number of cells filled with data. As before, the array will already be filled with strings, some of which contain the string "Angela". You will create a method called countItUp which returns and integer array containing the number of times each of the letters in my name occur within the strings within this array. For example, if the input array was wordFun =...
Write a method will accept an array of Strings. This method should return the string that comes after all the other strings in lexicographical order. (Assume all the Strings only contain lower case letters. In Example: No number, no Capitals and no Symbols) lastString({“hola”, “word”, “night”, “boom”}) → “word” lastString({“java”, “is”, “so”, “much”, “fun”}) → “so” lastString({“i”, “love”, “java”}) → “love” //precondition: words.length >0 public static String lastString(String[] words) { }
This method takes an array of Strings as a parameter and has no return value. The purpose of this method is to count all the characters in an array of strings. Count the number of characters in every string in the array and assign to numberChars. Count the number of lowercase letters in every string in the array and assign to numberLower. Count the number of uppercase letters in every string in the array and assign to numberUpper. Count characters...
package week_3; /** Write a method called countUppercase that takes a String array argument. You can assume that every element in the array is a one-letter String, for example String[] test = { "a", "B", "c", "D", "e"}; This method will count the number of uppercase letters from the set A through Z in the array, and return that number. So for the example array above, your method will return 2. You will need to use some Java library methods....
Given an array of strings, return true if each string's size is equal or greater than the one before, otherwise return false. The array will be length 2 or more. Example 1: If the names array contains… “Edwin” “Satish” “Solomon” “Massoud” …then the function call stringsIncreasing (names, 4) returns true. Example 2: If the names array contains… “Janet” “Linda” “Jackie” “Marta” …then the function call stringsIncreasing (names, 4) returns false since string Jackie comes before Marta and has more letters...
/** 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...
1) Write a method that will return the length of smallest string in an array of strings. smallestLength ({“hola”, “word”, “night”, “boom”}) → 4 smallestLength ({“java”, “is”, “so”, “much”, “fun”}) → 2 smallestLength ({“i”, “love”, “java”}) → 1 //precondition: strs.length>0 public static int smallestLength(String[] strs) { }