Skip to content

Commit 93adef9

Browse files
committed
sumDouble completed...gosh I am getting good :P
1 parent 80aa6a7 commit 93adef9

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

src/sumDouble.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*sumDouble
2+
* Given two int values, return their sum. Unless the two values are the same, then return double their sum.
3+
* sumDouble(1, 2) → 3
4+
* sumDouble(3, 2) → 5
5+
* sumDouble(2, 2) → 8
6+
*/
7+
public class sumDouble {
8+
9+
//Class for testing and setting dummy values
10+
public static void main(String [] args ) {
11+
int a = 2;
12+
int b= 2;
13+
14+
//Output tests
15+
System.out.println( sumDouble(a, b) );
16+
}
17+
public static int sumDouble(int a, int b) {
18+
int result = (a == b) ? (2*(a+b)) : (a + b);
19+
return result;
20+
}
21+
}
22+

0 commit comments

Comments
 (0)