Created
December 9, 2016 02:13
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
what the code