Skip to content

Commit 67a94c0

Browse files
committed
Added Exercise 009 - Positive Difference
1 parent dc7d84c commit 67a94c0

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

src/Java101ExerciseTest.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,16 @@ public void exercise008Test() {
9999
Java101Exercises.cube008(-5), 0.000001);
100100
}
101101

102+
@Test
103+
public void exercise009Test() {
104+
assertEquals("Java101Exercises.calcPositiveDifference009(4, 10) failed", 6,
105+
Java101Exercises.calcPositiveDifference009(4, 10));
106+
assertEquals("Java101Exercises.calcPositiveDifference009(-2, 17) failed", 19,
107+
Java101Exercises.calcPositiveDifference009(-2, 17));
108+
assertEquals("Java101Exercises.calcPositiveDifference009(-5, -28) failed", 23,
109+
Java101Exercises.calcPositiveDifference009(-5, -28));
110+
}
111+
102112
@Test
103113
public void exercise011Test() {
104114
assertEquals("exercise011Test failed test 01.",7.0, Java101Exercises.preformIndicatedOperation011("ADD",3, 4), 0.00001);

src/Java101Exercises.java

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,8 @@ public static boolean isEqual006(int a, int b) {
126126
*
127127
* LEVEL: BASIC
128128
*
129-
* @param a First integer
130-
* @param b Second integer
129+
* @param a First double
130+
* @param b Second double
131131
* @return Boolean flag reflecting equality
132132
*/
133133
public static boolean isGreaterThan007(double a, double b) {
@@ -147,6 +147,21 @@ public static double cube008(double a) {
147147
return 0.0;
148148
}
149149

150+
/**
151+
* Exercise 009 - Positive Difference
152+
* Write a method that accepts two integers and returns the positive difference between the two numbers.
153+
*
154+
* LEVEL: BASIC
155+
*
156+
* @param a First integer
157+
* @param b Second integer
158+
* @return Boolean flag reflecting equality
159+
*/
160+
public static int calcPositiveDifference009(int a, int b) {
161+
// TODO: Write code here
162+
return 0;
163+
}
164+
150165
/**
151166
* Exercise 011 - Preform Indicate Operation
152167
* Write a method with 3 parameters; a String and 2 doubles. The string will be an operation that the operation

0 commit comments

Comments
 (0)