Answered You can buy a ready-made answer or pick a professional tutor to order an original one.

QUESTION

Question 1: Odd Number ArrayCreate an array that holds the first 100 odd numbers.Iterate through the array and identify each number that is divisible by 5. Print the number, then double it.To clairfy,

Question 1: Username Method

Write a complete method to generate a username that matches these requirements:

·         first initial of first name

·         first five characters or last name (or full last name, if less than 5 characters long)

·         a two-digit random number

·         all lower case

Write code to go in a main method to read in the user’s first and last name and then invoke the method above and print out the generated username.

Question 2: Odd Number Array

Create an array that holds the first 100 odd numbers.

Iterate through the array and identify each number that is divisible by 5. Print the number, then double it.

To clairfy, when the code completes, the array will store [1, 3, 10, 7, 9, 11, 13, 30, ...]

Question 3: Negative Array Methods

Write two methods that convert the elements of an array to negative numbers (e.g., convert 3 to -3).

The first method changes the elements in the array passed in as a parameter. The second creates a new array that contains the negative elements of the array passed in as a parameter. In the second method, the array passed in as a parameter should not change. 

You can assume the initial array contains all positive numbers. The method headers are:

public void negateElementsInArray(int[] numbers)public int[] createNegativeElementsArray(int[] numbers)

Question 4: SubArray Method

Write a method to create a new array that contains only the elements between specified indices (inclusive). The method header is:

public int[] subArray(int[] numbers, int start, int end)

For example, if the method was invoked with {1, 5, 2, 4, 7, 3}, start = 1, end = 4, the method would return {5, 2, 4, 7}.

Include appropriate error checking for the indices.

Question 5: String Array

Write a method that converts all Strings in an array to upper case. The method header is:

public void convertToUpper(String[] words)

Question 6: Increasing Order Method

Write a complete method to determine whether an array of integers is in increasing order. For example, [4, 6, 8, 10, 10, 12] is increasing order but [4, 2, 6, 1, 1, 3] is not.

Question 7: Arrays and ArrayLists

In your own words, describe two similarities and two differences between arrays and ArrayLists. Describe one situation where you might want to use an array. Describe one situation where you might want to use an ArrayList.

Question 8: ArrayList Method

Write code statements to accomplish the following. Ask the user for a "code word." Then ask them to enter words repeatedly until they enter "quit" and store those words in an ArrayList. If the word does not contain the "code word," add it to the list. For example, if the "code word" is "cat," and the user enters "cater," "scatter," "cast," "quit," then only "cast" would be stored on the list. Output the number of words on the list.

Question 9: Mode Method (Challenge!)

Write a complete method to find the mode of an integer array. The mode is the number that appears the most frequently. For example, in the array [0, 4, 2, 7, 2, 4, 2], the mode is 2, because it appears three times. For this method, if there is more than one mode, you can return either. For example, for the array [4, 1, 3, 1, 4], you could return either 1 or 4.

Note that this method is more challenging that what I would ask you to do on the homework or an exam!

The method header is: 

public int findMode(int[] numbers)

Question 10: String Method Trace A

What is the value of text after each statement below? Also, show output that is printed, when applicable.

String text = "California";text.toLowerCase();System.out.println(text.toLowerCase());text = text.toLowerCase();System.out.println(text.length());text = text.substring(2,6);System.out.println(text.substring(1));text = text.substring(1,2);System.out.println(text + 1 + 3);System.out.println(1 + 3 + text);System.out.println(text.equals("i"));System.out.println(text=="i");System.out.println(text.equalsIgnoreCase("I"));

Question 11: String Method Trace B

What is the value of name after each statement below? Also, show output that is printed, when applicable.

String name = “Dr. Suess”;System.out.println(name.toLowerCase());name.toUpperCase();name = name.toLowerCase();boolean same1 = name.equals(“dr. suess”);boolean same2 = name==“dr. suess”;System.out.println(same1 + “ and ” + same2);System.out.println(name.length());name.replace(‘s’,’x’);name = name.substring(2, 7);name += 1 + 3 + “author”;

Question 12: String vs String Builder

In your own words, explain the difference in these classes. What are some pros and cons of each class?

Show more
  • @
  • 22 orders completed
ANSWER

Tutor has posted answer for $10.00. See answer's preview

$10.00

******** ******** ********************** class ******** * ****** static void ************* args) { ******* ** = new ****************** *********************** **** ***** Name"); ****** ********* = scnextLine(); *********************** your **** ******* ****** lastName = ************* *************************** ******** * * + generateUsername(firstName *********** * ****** static ****** *********************** ********* ****** ********* { ****** username * *** if(firstName ** null ********** ********************** ******** * ******************************** * ************* **** ********** ********************* ************************** ******** * ******** + ********************** ***** { ******** * ******** * ************************************* } * ************************ username * ******** * **************************** } return ********************** ************ ******** ***** ************** * public static **** ************* ***** * *** ***************** * 100; int[] ************** = *** int[NUMBER_OF_ELEMENT]; *** ***** * 0; *** **** * * ** i **** ***************** * ** **** { ** ** % * ** 0) * ********************* * ** ******** * * for **** i = 0; * **** count; **** * if ****************** * 5 ** ** * ************************************ ***************** = ***************** * ** } * ****************** ************ Current ******* ** ** ***** >>> "); *** (int * * ** * **** ****** **** { Systemoutprint(oddNumberArray[i] * " *** } ************ ******** void negateElementsInArray(int[] number) * *** **** * * ** i **** numberlength; **** * number[i] = ********* * (-1); * ******* void createNegativeElementsInArray(int[] ******* { ***** ******************** = *** ****************** *** **** * * ** * **** ************* **** * *********************** = number[i] * ***** * ************* ******** ***** ************** numbers int ***** *** end) * int[] ******** * *** ***************** *** count * ** *** **** * * ****** * <= **** i++) * *************** * numbers[i]; ******** } ****** ********* ************* ******** **** convertToUpper(String[] words) * *** (int * * ** * **** ************ **** * ******** * ********************** * ************* ******** **** ************************** ********* for **** * * 0; * < **************** **** * if(!(numbers[i] **** numbers[i+1])){ ************************* *** *** ** ********** ******** return; * * ************************* are ** ********** order *** ************* *************** Array *** ArrayList can **** ********* elements in themØ ***** *** ********* *** ********* ******* ***** and ArrayList **** ******** **** ************************************ ** static ** sizeArrayList ** dynamic ** size *** ******** ***** ************* when **** elements *** addedArray *** ******* **** primitive ***** *** objectsArrayList ****** ******* ********* typesArrays **** ** ********* **** ** ******* with ***** ****** ** ******** * ****** *** **** straightforward ** ****** *** ********* ******** over *********** get() **** ****** ******* **** ********* when * **** multidimensional *************** ** ********* in *** situation **** number ** ******** ** ******* *** we are dealing with objects **** references  Solution ******** ************************ ******************* ********************** ***** CodeWord { ****** ****** **** ************* args) { Scanner sc * new ****************** ****************** words * *** ArrayList<String>(); ************************ enter the **** Word : "); String **** = ************* ****** choice * ""; ** * ************************ ***** *** **** : "); choice * ************* ** ********************** ********** ********************** * ***************** * * ***** ************************ ************************* ** *** ***** ******* for (String **** * ****** * Systemoutprintln(word); * ************** ******** *** findMode(int[] ******** * *** ******** * ** int maxCount * 0; for (int i * ** * < numberslength; **** * int ***** = 0; *** (int * * 0; * **** ************** ++j) * if (numbers[j] == numbers[i]) ++count; } if ****** **** ********* { maxCount * ****** ******** * *********** } * return maxValue; ************* 10:a) ****** text * ***************** ******** ***** ‘California’b) texttoLowerCase();text ** ******** to ****** ********* but *** ******** ** *********** ***************************************** *** ** californiad) **** * texttoLowerCase();text ******** ********* to lowercase;e) ************************************* length of **** ** **** **** * ************************** **** the ***** ** ********* from index * to * (last ***** excluded) ** *** *** ***** of text * ****** Systemoutprintln(textsubstring(1));Print the value of **** **** ***** * **** **** ** ***** text = textsubstring(12);Assigned text the value ** ********* ** **** **** 1-2 ***** ** **** * *** ********************* * 1 + ******** *** ** ** ************ ***** as ******** ****************** * * * *********** ** as ***** two digits are ***** *** then others *** ************** Systemoutprintln(textequals("i"));True : ***** the ******* ***** ** text * **** Systemoutprintln(text=="i");False: ***** **** ********* ** ******** ****** **** ******* Systemoutprintln(textequalsIgnoreCase("I"));True : ***** **** *********** ** ******* ** *** ****** ** equal  Solution ***** ****** **** * *** *************** **** ******** ***** Dr Suessb) ****************************************** the name ****** ** ********* ******** ** ******* *************************** ********* is ********* ** name *** as *** not ******** ** **** so there **** be ** ****** ** ****** **** = ********************** ******** *** ***** ** **** in ********* ** *** ******* = ** ******* ******* ***** = ************** suess");Here ***** *** ******** which ** equal ** ***** * ****** boolean ***** * ********* *********** ********** are ******** ***** ** *** ***** ** ***** * ******* ********************** + " and * * same2);Prints out the ***** so Output: **** and falseh) ************************************ out *** ****** ** **** ****** ***** is *** ********************** ******* Replace command ** used *** *** ******** to name so no ****** ** ****** **** * namesubstring(2 ******* ******** *** value ** ********* ** **** **** ***** * **** *** **** * ***** **** ** * * * + ************* **** is assigned ***** ***** ** **** * * * * + ****** so *** ***** **** ** **** = ************** is **** ******** *** ***** pick **

Click here to download attached files: Java Solution.docx
or Buy custom answer
LEARN MORE EFFECTIVELY AND GET BETTER GRADES!
Ask a Question