Question: write a program in Filter.java will filter an array of integers based on a given command option. Your program will have to support 2 command

 write a program in Filter.java will filter an array of integers based on a given command option.

Your program will have to support 2 command options and have the described behavior:

  • even - prints out a list of all the even integers provided as argument
  • odd - prints out a list of all odd integers provided as argument

Filter will always have either even or odd as the first argument and have either none or some integers as command line arguments.

If there are zero integers provided as command line arguments, print nothing (not even a new line)

$ javac Filter.java $ java Filter even -1 0 1 2 3 4 5 0 2 4 $ java Filter odd -1 0 1 2 3 4 5 -1 1 3 5 $ java Filter odd $ java Filter even $ java Filter even -2 -4 -6 -8 -2 -4 -6 -8

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Heres the implementation of the Filter program in Java java public class Filter public static void m... View full answer

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!