JUnitDue Monday, September 18 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 methodsAreaCalculationMethod.javaDegreeConversionMethod.javaCompoundInterestMethod.javaAreaCalculationMethodTest.javaAddFiveTest.javaAddBothTest.javacollaborators.txtAreaCalculationMethod.java
Download the AreaCalculationMethod.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.
Unlike with previous labs, you may not modify the code in the main method.
More details are in the comments of AreaCalculationMethod.java.
Example output of the program is shown below, with user input shown in bold:
Enter width: 2 Enter height: 3 Area: 6
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.
AreaCalculationMethodTest.java
Download the AreaCalculationMethodTest.java file, being sure to put it in the same folder/directory as your AreaCalculationMethod.java file from step 1.
AreaCalculationMethodTest.java contains a bunch of tests for the calculateArea method you wrote in step 1.
Use the instructions here to open AreaCalculationMethodTest.java as a tests file, then compile and run the tests.
All the tests have been provided, and assuming you implemented your calculateArea method correctly, they should all pass.
While you don't need to edit any code for this step, be sure to save AreaCalculationMethodTest.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.
AddFive.java and AddBoth.java From the Previous Lab
In the previous lab, you had to write code in AddFive.java and AddBoth.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.
AddFiveTest.java
Download the AddFiveTest.java file, being sure to put it in the same folder/directory as your AddFive.java file.
AddFiveTest.java contains a bunch of tests for the addFive method you wrote in the previous lab.
One test has already been provided for you, namely zeroPlusFiveIsFive.
You'll need to write two more tests, namely:
onePlusFiveIsSix: Tests that addFive called with the parameter 1 produces 6, using assertEqualstwoPlusFiveIsSeven: Tests that addFive called with the parameter 2 produces 7, using assertEqualsAddBothTest.java
Download the AddBothTest.java file, being sure to put it in the same folder/directory as your AddBoth.java file.
AddBothTest.java contains a bunch of tests for the addBoth method you wrote in the previous lab.
One test has already been provided for you, namely zeroPlusOneIsOne.
You'll need to write three more tests, namely:
onePlusOneIsTwo: Tests that addBoth called with the parameters 1 and 1 produces 2, using assertEqualstwoPlusOneIsThree: Tests that addBoth called with the parameters 2 and 1 produces 3, using assertEqualstwoPlusFourIsSix: Tests that addBoth called with the parameters 2 and 4 produces 6, using assertEqualsLog into Canvas, and go to the COMP 110L class. Click “Assignments” on the left pane, then click “Lab 5”. From here, you can upload your answers and your code. Specifically, you must turn in the following six files:
AreaCalculationMethod.javaDegreeConversionMethod.javaCompoundInterestMethod.javaAreaCalculationMethodTest.classAddFiveTest.javaAddBothTest.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 five files.
You can turn in the assignment multiple times, but only the last version you submitted will be graded.