Skip to content

Instantly share code, notes, and snippets.

@nazmul202101
Created December 9, 2016 02:13
Show Gist options
  • Save nazmul202101/1031d61df779131148742843d08e9085 to your computer and use it in GitHub Desktop.
Save nazmul202101/1031d61df779131148742843d08e9085 to your computer and use it in GitHub Desktop.
Given an int n, return the absolute difference between n and 21, except return double the absolute difference if n is over 21.
//Given an int n, return the absolute difference between n and 21, except return double the absolute difference if n is over 21.
//diff21(19) → 2
//diff21(10) → 11
//diff21(21) → 0
public int diff21(int n) {
if(n<=21){
return 21-n;
}
else if(n>21){
return ((n-21)*2);
}
return 0;
}
@descamae
Copy link

what the code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment