Question: Task #4: Command Line Arguments Part A. Create a java class/file called CommandLines.java with a mainmethod. In the main method write a loop that traverses

Task #4: Command Line Arguments

Part A.

Create a java class/file called CommandLines.java with a mainmethod.

In the main method write a loop that traverses through the argsarray and prints the contents of each element in the followingformat:

args[0]: hello
args[1]: how

Save this java file in the User folder in your C drive.

Open the command prompt window and compile the program bytyping:

javacCommandLine.java

NOTE: MAKE SURE YOUR ARE IN THE CORRECT DIRECTORY (CHECK YOURPATH)

After a successful compilation of the program, run the followingcommand by writing the arguments-

java CommandLine argument-list

For example – java CommandLine My favorite color is Purple

Press Enter and you will get the desired output.

After performing the above steps, we will get the followingoutput:

args[0]: My
args[1]: favorite
args[2]: color
args[3]: is
args[4]: purple

part B.

Traverse through your array and print the names that contain thesubstring "ma" and whose length is less than 5

Test case:

kim andy mary jose khoi omar maryam henryemma

part C

Traverse through your array and calculate the average of all thenumbers less than 7

Test case:

2 11 10 4 5 7 14 4

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!