sumDouble
Problem:
Problem:
Given two int values, return their sum. Unless the two values are the same, then return double their sum.
Test Cases:
sumDouble(1, 2) → 3
sumDouble(3, 2) → 5
sumDouble(2, 2) → 8
sumDouble(3, 2) → 5
sumDouble(2, 2) → 8
Solution:
public int sumDouble(int a, int b) {
if(a==b)
{
return 2*(a+b);
}
return (a+b);
}
if(a==b)
{
return 2*(a+b);
}
return (a+b);
}
No comments:
Post a Comment