Question: Task # 1 : Command Line Arguments Part A . Create a java class / file called CommandLines.java with a main method. In the main
Task #: Command Line Arguments
Part A
Create a java classfile 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: hello
args: 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 argumentlist
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: My
args: favorite
args: color
args: is
args: purple
part B
Traverse through your array and print the names that contain the substring ma and whose length is less than
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
Test case:
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
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
