RangeFilter.java

public class RangeFilter {
public static void main(String[] args) {

// read in two command-line arguments
int lo = Integer.parseInt(args[0]);
int hi = Integer.parseInt(args[1]);

// repeat as long as there’s more input to read in
while (!StdIn.isEmpty()) {

// read in the next integer
int t = StdIn.readInt();

// print out the given integer if it’s between lo and hi
if (t >= lo && t <= hi) {
StdOut.print(t + " ");
}
}
StdOut.println();
}
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s