-
-
Save nazmul202101/b7cbc3d1a1df468e98ff8d715620c6e2 to your computer and use it in GitHub Desktop.
Given 2 positive int values, return the larger value that is in the range 10..20 inclusive, or return 0 if neither is in that range.
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 2 positive int values, return the larger value that is in the range 10..20 inclusive, or return 0 if neither is in that range. | |
//max1020(11, 19) → 19 | |
//max1020(19, 11) → 19 | |
//max1020(11, 9) → 11 | |
public int max1020(int a, int b) { | |
if(a>=10 || a<=20){ | |
return a; | |
} | |
else if(b>=10 || b<=20){ | |
return b; | |
} | |
else if(a>b){ | |
return a; | |
} | |
else if(b>a){ | |
return b; | |
} | |
return 0; | |
} |
int holda = 0;
int holdb = 0;
if(a>=10 && a<=20){
holda = a;
}else{
holda = 0;
}
if(b>=10 && b<=20){
holdb = b;
}else{
holdb=0;
}
return Math.max(holda,holdb);
}
wrong answer
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ya thats no good