Question: Task # 1 : Command Line Arguments Part A . Create a java class / file called CommandLines.java with a main method. In the main

Task #1: Command Line Arguments
Part A.
Create a java class/file called CommandLines.java with a main method.
In the main method write a loop that traverses through the args array and prints the contents of each element in the following format:
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 by typing:
javac CommandLine.java
NOTE: MAKE SURE YOU ARE IN THE CORRECT DIRECTORY (CHECK YOUR PATH)
After a successful compilation of the program, run the following command 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 following output:
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 the substring "ma" and whose length is less than 5
Test case:
kim andy mary jose khoi omar maryam henry emma
part C
Traverse through your array and calculate the average of all the numbers less than 7
Test case:
21110457144
Part D:
print the results from part C to a file called output.txt. Take a screenshot of both the source code and the text file output.txt.

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!