Question: We will work together to write a Java application EveryNth.java that takes a number as its only command - line parameter, reads words from a

We will work together to write a Java application EveryNth.java that takes a number as its only command-line parameter, reads words from a file redirected from the standard input (a keyboard Scanner), then it should output every nth word, space-separated, from the text it read in, where n was specified as the program's command-line parameter. If no command-line parameter is provided or the one provided is not a positive integer, your program should print an appropriate error message and exit. Otherwise, your program should not issue any prompts or produce any other output except the n words.
This is a good example of a place where running the program from the command line can come in handy. If you have a plain text file atest.txt with the words to use as input, you could run the program, redirecting standard input to come from the file as follows:
java EveryNth 10 atest.txt
Further, if you want to store the output of your program into a new plain text file nonsense.txt, using redirection of standard output:
java EveryNth 10 atest.txt > testOut.txt
Add your testOut.txt to your repository, and then commit and push your completed code and the output file.import java.util.*;
7
8vv public class EveryNth {
9vv public static void main(String[] args){
10
11// Check command line argumemts
if (){
System.out.println("");
System.exit(1);
}
??? Create an input scanner from the standard input
??? Get the input
// Break it into words
// Display every nth word
}
}
26
 We will work together to write a Java application EveryNth.java that

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 Databases Questions!