Computer Science 225
Advanced Programming
Spring 2022, Siena College
Agenda
You can find the link to create a GitHub repository that includes a Java file we will begin with in Canvas.
We will work together to write a Java application Nonsense.java that takes a number as its only command-line parameter, reads words from the standard input (a keyboard Scanner), stopping when Ctrl-d is entered, then it should output n space-separated words each chosen randomly from among those 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 words.txt with the words to use as input, you could run the program, redirecting standard input to come from the file as follows:
java Nonsense 10 < words.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 Nonsense 10 < words.txt > nonsense.txt
Add nonsense.txt to your repository, and then commit and push your completed code and that output file.
Terminology
Examples