See this link for Assignment
Policies, Submission Instructions, and Grading Guidelines.
1. Write a Java application that does the following:
2. The user should enter INTEGERS as COMMAND LINE ARGUMENTS.
3. The user can enter any amount of INTEGERS as COMMAND LINE ARGUMENTS. For example, the user could enter no command line arguments at all. Or just 1 command line argument. For example, the number 12345. Or they may enter 5 command line arguments. For example: 2 2 2 4 6. Or they might enter non-integer data. For example: one 2 three 5.
4. Display the number of command line arguments.
5. Display all of the command line arguments.
6. Count the number of the command line arguments that are INTEGERS.
7. Display the count.
8. Display all of the command line arguments that are INTEGERS.
9. Calculate the sum of the INTEGERS.
10. Display the sum.
11. Calculate the average of the INTEGERS.
12. Display the average.
13. Use either “if” statements or try-catch blocks to determine the difference between integers and non-integer data.
14. See
example command line arguments and output below.
15. WARNING: DO NOT try to write the whole program at once.
Make sure the most basic part works first. Then, gradually add to it until your
program is complete. Writing methods will help you organize your code as well.
Command line arguments: (none)
Program output:
Number of command line arguments
is 0.
Command line arguments: 12345
Program output:
Number of command line arguments
is 1.
They are: 12345
The number of integers is 1.
They are: 12345
The sum is: 12345
The average is: 12345
Command line arguments: 2 2 2 4 6
Program output:
Number of command line arguments
is 5.
They are: 2 2 2 4 6
The number of integers is 5.
They are: 2 2 2 4 6
The sum is: 16
The average is: 3.2
Command line arguments: one 3
three 4
Program output:
Number of command line arguments
is 5.
They are: one 3 three 4
The number of integers is 2.
They are: 3 4
The sum is: 7
The average is: 3.5
© 2007 William Albritton