Skip to content

Instantly share code, notes, and snippets.

@nazmul202101
Created December 9, 2016 19:15
Show Gist options
  • Save nazmul202101/c5dca0661d3665d16168a1c7edf980cb to your computer and use it in GitHub Desktop.
Save nazmul202101/c5dca0661d3665d16168a1c7edf980cb to your computer and use it in GitHub Desktop.
Given two int values, return their sum. Unless the two values are the same, then return double their sum.
//Given two int values, return their sum. Unless the two values are the same, then return double their sum.
//sumDouble(1, 2) → 3
//sumDouble(3, 2) → 5
//sumDouble(2, 2) → 8
public int sumDouble(int a, int b) {
if(a==b){
return ((a+b)*2);
}
else{
return a+b;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment