Supplied file(s)
(copy from $sup03)
DemoCompareAlgorithms.jar (the demo executable)
CompareAlgorithms.txt (the TextItems file of program description)
Files to submit CompareAlgorithms.jar (your executable jar file)
CompareAlgorithms.java (your source code file)
my_tests.sh (your completed testing script)
Where to put them Copy them to your u##/submissions/s03 folder
When they're due Sun, Oct 26, 2025 @11:59pm

Overview

This week your task is to write a program that tests or "profiles" three different algorithms that compute the sum of all positive integers from 1 up to a value input at the command line. The three algorithms are those shown as algorithms A, B and C in this image.

Your tester will again be an executable jar file that must perform in the same way as the supplied executable.

Steps to Perform

  1. Begin by copying the supplied files to your uxx account. Develop your solution in a location other than the submission directory, and only copy your solution files to the submission directory once you have finished and tested your solution.
  2. Run the supplied sample executable file DemoCompareAlgorithms.jar with no command-line input to see the opening identification screen and the program information screen.
  3. Run the supplied sample executable with some test input values until you understand how your program is to work, since its behavior must replicate the behavior of the sample executable.
  4. Now design, and then write, a Java program that will emulate as closely as possible the behavior of the sample executable. As you think about the timing and operation-counting aspects of the problem, keep in mind that you have two new classes (Stopwatch and OperationCounter), which are available from the jxtra directory online that will help you with these tasks. Be sure to study the interfaces to these classes so you know how to use them.
  5. Prepare your my_tests.sh testing script.
  6. When 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 the self-assessment comment of your submission.
  7. Finally, submit the required files by copying just those files into the submissions/s03 directory in your u## account.

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

  1. Here is a design hint: You must have a single source code file to submit, but you can of course have a single file containing two classes: for example, you can have a public "driver" class that handles the "infrastructure" aspects of the problem, and uses an object of a second class to do the actual testing of the three algorithms. There is no problem with having two classes in the same file, but (as you know) only one of them can be public, so in this case that means that your public class must be named CompareAlgorithms. Also note that this approach will give two compiled classes, both of which must be included in your jar file.
  2. Note that the reported time for each algorithm is in seconds, each operation (assignment or arithmetic) is assumed to take the same amount of time and has a single unit of artificial delay time applied to it (using the delay() method of the Stopwatch class).
  3. Note as well that the times are given to three decimal places, and that the time values are right-justified within their field while the number of assignments and the number of arithmetic operations are both left-justified.