JUnit
Due Friday, December 1 at 11:59 PM
By the time you have completed this work, you should be able to:
JUnit
to write and execute basic tests for methodsPerimeterCalculationMethod.java
DegreeConversionMethod.java
CompoundInterestMethod.java
PerimeterCalculationMethodTest.java
MultiplySevenTest.java
MultiplyBothTest.java
collaborators.txt
PerimeterCalculationMethod.java
Download the PerimeterCalculationMethod.java
file, and open it in jGrasp (or a text editor of your choice).
You'll need to implement the concatenate
method, without modifying the main
method.
You may not modify the code in the main
method.
More details are in the comments of PerimeterCalculationMethod.java
.
Example output of the program is shown below, with user input shown in bold:
Enter width: 2 Enter height: 3 Perimeter: 10
DegreeConversionMethod.java
Download the DegreeConversionMethod.java
file, and open it in jGrasp (or a text editor of your choice).
You will need to define a method in order to get this code compiling, and you may not modify the main
method.
DegreeConversionMethod.java
contains more details in the comments.
Example output of the program is shown below, with user input shown in bold:
Enter temperature in Celsius: 4.5 Fahrenheit: 40.1
CompoundInterestMethod.java
Download the CompoundInterestMethod.java
file, and open it in jGrasp (or a text editor of your choice).
You will need to define a method in order to get this code compiling, and you may not modify the main
method.
CompoundInterestMethod.java
contains more details in the comments.
Example output of the program is shown below, with user input shown in bold:
Enter principle (long): 53 Enter annual interest rate (double): 0.02 Enter number of times interest is compounded per year (int): 6 Enter number of years invested (int): 18 Compound interest including principal: 75.92099374307139
If you're using jGrasp, you'll need to configure jGrasp to use JUnit. You can do this by following the instructions here. You only need to do this once per computer you have jGrasp installed on.
PerimeterCalculationMethodTest.java
Download the PerimeterCalculationMethodTest.java
file, being sure to put it in the same folder/directory as your PerimeterCalculationMethod.java
file from step 1.
PerimeterCalculationMethodTest.java
contains a bunch of tests for the calculatePerimeter
method you wrote in step 1.
Use the instructions here to open PerimeterCalculationMethodTest.java
as a tests file, then compile and run the tests.
All the tests have been provided, and assuming you implemented your calculatePerimeter
method correctly, they should all pass.
While you don't need to edit any code for this step, be sure to save PerimeterCalculationMethodTest.class
in a safe spot.
This file is produced automatically by jGrasp upon compiling and running the tests.
This file will later be submitted along with the rest of the code you write.
MultiplySeven.java
and MultiplyBoth.java
From the Previous Lab
In the previous lab, you had to write code in MultiplySeven.java
and MultiplyBoth.java
.
Copy over those two files into the same folder/directory where the rest of the files for this lab are.
In this lab, you will write tests for the methods you wrote in the previous lab.
MultiplySevenTest.java
Download the MultiplySevenTest.java
file, being sure to put it in the same folder/directory as your MultiplySeven.java
file.
MultiplySevenTest.java
contains a bunch of tests for the multiplyBy7
method you wrote in the previous lab.
One test has already been provided for you, namely zeroTimesSevenIsZero
.
You will need to write two more tests, which are described in the comments in the file.
MultiplyBothTest.java
Download the MultiplyBothTest.java
file, being sure to put it in the same folder/directory as your MultiplyBoth.java
file.
MultiplyBothTest.java
contains a bunch of tests for the multiplyBoth
method you wrote in the previous lab.
One test has already been provided for you, namely zeroTimesOneIsZero
.
You will need to write three more tests, which are described in the comments in the file.
Log into Canvas, and go to the COMP 110 class. Click “Assignments” on the left pane, scroll down to “Weekly Activities”, then click “Lab 2”. From here, you can upload your answers and your code. Specifically, you must turn in the following six files:
PerimeterCalculationMethod.java
DegreeConversionMethod.java
CompoundInterestMethod.java
PerimeterCalculationMethodTest.class
MultiplySevenTest.java
MultiplyBothTest.java
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.