Lab 14: Iterating Over Arrays with Loops


Due Wednesday, March 28 at 11:59 PM

Goals for This Lab

By the time you have completed this work, you should be able to:

Provided files:

Step-by-Step Instructions

Step 1: Edit SumMinMaxArgs.java

Download the SumMinMaxArgs.java file, and open it in jGrasp (or a text editor of your choice). This program takes a number of command line arguments, parses them as ints, and then displays:

  1. The arithmetic sum of the arguments
  2. The smallest argument
  3. The largest argument

If you're unsure how to pass command-line arguments to a program with jGrasp, see this tutorial. Example output of this program with the command-line arguments 1 2 3 4 5 is shown below:

Sum: 15
Min: 1
Max: 5

Further example output for the command-line arguments 87 23 42 91 -4 is shown below:

Sum: 239
Min: -4
Max: 91

Step 2: Open SumMinMaxArgsTest.java as a Test File

Download the SumMinMaxArgsTest.java file, being sure to put it in the same folder/directory as your SumMinMaxArgs.java file. This file contains tests for the code you wrote in the previous step. Open this file in jGrasp as a test file, using the same instructions you've used in previous labs. For this lab, you do not need to submit the tests, and you are not required to write any of your own tests. However, for full credit, all the tests must pass.

Step 3: Turn in Your Solution Using Canvas

Log into Canvas, and go to the COMP 110L class. Click “Assignments” on the left pane, then click “Lab 14”. From here, you can upload your code. Specifically, you must turn in the following file:

In addition, if you collaborated with anyone else, be sure to download collaborators.txt and write the names of the people you collaborated with in the file, one per line. Please submit this file along with the other file.

You can turn in the assignment multiple times, but only the last version you submitted will be graded.