Advertisement
Guest User

Untitled

a guest
Dec 8th, 2016
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. //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.
  2.  
  3. //max1020(11, 19) → 19
  4. //max1020(19, 11) → 19
  5. //max1020(11, 9) → 11
  6.  
  7. public int max1020(int a, int b) {
  8. if(a>=10 || a<=20){
  9. return a;
  10. }
  11.  
  12. else if(b>=10 || b<=20){
  13. return b;
  14. }
  15.  
  16. else if(a>b){
  17. return a;
  18. }
  19.  
  20. else if(b>a){
  21. return b;
  22. }
  23.  
  24. return 0;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement