Computers and Technology

First, launch NetBeans and close any previous projects that may be open (at the top menu go to File ==> Close All Projects). Then create a new Java application called "StringSlicer" (without the quotation marks) that uses methods to:
1. Get a String from the user at the command line
2. Populate an ArrayList of Character data (the wrapper class), with each char in the String represented as a separate
Character element in the ArrayList
3. Output each Character to the command line, each on a separate line
NOTE: For this assignment and all future assignments that deal with methods, you should be calling the appropriate method to do the task indicated, rather than implementing the task logic in the main method itself.
One of the PA requirements is to use an ArrayList where each element is a char. There are several
implementation approaches. The notes below use an ArrayList and String variable locally declared in
main. The use of three methods is required for this PA.
Method 1: The first method has no parameters and returns a string. Within the method body, the user
should be prompted for a string and the string should be read into a local string variable using the next()
method. There’s no requirement for entering a multi-word phrase – so using the next() method is fine.
The user-entered string is then returned to main.
The header of the method should be similar to this:
public static String input()
Method 2: This method has two parameters, the string returned from the first method and the ArrayList
(which you are going to fill in). Use a for loop to go character by character through the string (use of the
charAt method works well). Store each of the characters of the input string into the ArrayList using the
add() method.
The header of the method should be similar to this where ‘aString’ is the returned string from Method 1,
and charArray is the ArrayList declared in main.
public static void process(String aString, ArrayList charArray)
Method 3 has the ArrayList as a parameter. The method uses a for loop to printout each of the elements
in the ArrayList using the get method.
The method header should look similar to this:
public static void output(ArrayList charArray)
An approach for implementing main, pseudocode:
Declare local ArrayList
Declare local String variable
Call ‘input’ method which no parameters and returns a String
Call ‘process’ method which has the String and the ArrayList as parameters
Call ‘output’ method which has the ArrayList as a parameter
An example run:
Enter a string:
rabbit
r
a
b
b
i
t

answer
Answers: 1

Other questions on the subject: Computers and Technology

image
Computers and Technology, 21.06.2019 15:00, notsobright10
Marissa is a high school student who wants to be a hydroelectric production manager. she talks to her guidance counselor about her education path, and the counselor says that she needs to get an associate’s degree from a four-year college and will follow that with significant on-the-job training. what error did the counselor make while advising marissa? marissa will not have on-the-job training. marissa also needs a three-year apprenticeship. marissa only needs to attend a two-year college. marissa needs a bachelor’s degree.
Answers: 1
image
Computers and Technology, 22.06.2019 04:30, kkeith121p6ujlt
Eye injuries usually occur as a result of all of the following things, except: a) proper machine operation b) battery explosion c) falling or flying debris d) electric welding arc
Answers: 2
image
Computers and Technology, 23.06.2019 07:30, emilyplays474
What key should you press and hold to select and open multiple files at one time? enter alt control esc
Answers: 1
image
Computers and Technology, 23.06.2019 13:30, small77
Font size, font style, and are all aspects of character formatting.
Answers: 2
Do you know the correct answer?
First, launch NetBeans and close any previous projects that may be open (at the top menu go to File...

Questions in other subjects:

Konu
History, 05.11.2019 21:31