Lab 8: More Testing, Modulo, and if


Due Tuesday, October 11 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 Mod.java

Download the Mod.java file, and open it in jGrasp (or a text editor of your choice). You will need to implement a method that uses modulo (%) to make the code correctly compile and run. You may not modify the code in the main method. Example output of the program is shown below, with user input shown in bold:

Enter an integer: 2
Enter a second integer: 3
Result: 2

Step 2: Open ModTest.java as a Test File, and Edit It

Download the ModTest.java file, being sure to put it in the same folder/directory as your Mod.java file. This file contains a number of tests for the method you wrote in the previous step. Open this file in jGrasp as a test file, using the same instructions you used in the previous lab. You need to write a number of tests in this file, and all of them must pass. The comments in the file provide more details.

Step 3: Edit IntCompare.java

Download the IntCompare.java file, and open it in jGrasp (or a text editor of your choice). You will need to implement two methods in this file which return boolean results, reflecting whether or not one value is greater than or less than another. The comments in the file provide more details. You may not modify the code in the main method. Example output of the program is shown below, with user input shown in bold:

Enter first integer: 2
Enter second integer: 3
Less than: true
Greater than: false

Further example output of the program is shown below, with user input shown in bold:

Enter first integer: 2
Enter second integer: 2
Less than: false
Greater than: false

Step 4: Open IntCompareTest.java as a Test File, and Edit It

Download the IntCompareTest.java file, being sure to put it in the same folder/directory as your IntCompare.java file. This file contains a number of tests for the methods you wrote in the previous step. Open this file in jGrasp as a test file, using the same instructions you used in the previous lab. You need to write a number of tests in this file, and all of them must pass. The comments in the file provide more details.

Step 5: Edit MinMax.java

Download the MinMax.java file, and open it in jGrasp (or a text editor of your choice). This code in this file does something much like IntCompare.java, only now it needs to return int values instead of boolean values. The comments in the file provide more details. You may not modify the code in the main method. Example output of the program is shown below, with user input shown in bold:

Enter first integer: 3
Enter second integer: 4
Min: 3
Max: 4

Further example output of the program is shown below, with user input shown in bold:

Enter first integer: 1
Enter second integer: 1
Min: 1
Max: 1

Step 6: Open MinMaxTest.java as a Test File, and Edit It

Download the MinMaxTest.java file, being sure to put it in the same folder/directory as your MinMax.java file. This file contains a number of tests for the methods you wrote in the previous step. Open this file in jGrasp as a test file, using the same instructions you used in the previous lab. You need to write a number of tests in this file, and all of them must pass. The comments in the file provide more details.

Step 7: Turn in Your Solution Using Canvas

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

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 six files.

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