Supplied file(s)
(copy from $sup04)
DemoNamesAndSquares.jar (the demo executable)
NamesAndSquares.txt (the TextItems file of program description)
Node.java (the generic Node class to be used for both names and integers)
Files to submit NamesAndSquares.jar (your executable jar file)
NamesAndSquares.java (your source code file)
my_tests.sh (your completed testing script)
Where to put them Copy them to your u##/submissions/s04 folder
When they're due Sun, Nov 16, 2025 @11:59pm

Overview

This week the program you must develop is designed to increase your comfort level in working with simple linked structures. In particular, you will write a program that reads and processes input from a textfile, and each value input from the file may be a name (that is, a string) or an integer.

Steps to Perform

  1. Download the sample executable DemoNamesAndSquares.jar, run it first with no command-line input, and study the program description.
  2. Next create one or more sample input files, and run the program with a file name as the command-line input. Study the output format produced until you are comfortable with how the program behaves.
  3. Now design, then write, a Java program that will emulate as closely as possible the behavior of the sample executable, and put all the necessary pieces together in the required executable jar file, in the usual way.
    Note that your program must use the supplied Node.java file and create and manipulate appropriate sequences of linked nodes using the Node class in that file.
  4. When you have completed your testing script and everything is working correctly, make a final check before submission to ensure your source code is identified, formatted, and documented properly. And don't forget to complete your self-assessment comment.
  5. Finally, submit the required files by copying them (and only them) into the submissions/s04 directory in your u## account.

Additional Notes, Requirements, Specifications and/or Hints (if any)

  1. By using a generic Node class you can have one sequence of linked nodes for the integer values and a second sequence of linked nodes for the names, with both using the same Node class.
  2. First hint: Consider throwing a NumberFormatException to distinguish between integer and name values read from the file.
  3. Second hint: This program requires displaying two kinds of data, integers and strings. So ... you can have two separate methods, one to display each type of data item, but since both types are displayed using the same output format, you can also use a single generic method to display both types.
  4. It may occur to you that this program could be written in other ways and using other data structures. However, the whole point of this submission is to produce an implementation that does, in fact, use linked nodes, and if your program does not solve the problem in this way, you will not receive any credit for this submission.