Java > Warmup-1 > in1020 (CodingBat Solution)

Problem:

Given 2 int values, return true if either of them is in the range 10..20 inclusive.

in1020(12, 99) → true
in1020(21, 12) → true
in1020(8, 99) → false


Solution:

public boolean in1020(int a, int b) {
  if ((a >= 10 && a <= 20) || (b >= 10 && b <= 20))
    return true;
  else
    return false;
}


1 comment :

  1. public boolean in1020(int a, int b) {
    return 10 <= a && a <= 20 || 10 <= b && b <= 20;
    }

    ReplyDelete

Follow Me

If you like our content, feel free to follow me to stay updated.

Subscribe

Enter your email address:

We hate spam as much as you do.

Upload Material

Got an exam, project, tutorial video, exercise, solutions, unsolved problem, question, solution manual? We are open to any coding material. Why not upload?

Upload

Copyright © 2012 - 2014 Java Problems  --  About  --  Attribution  --  Privacy Policy  --  Terms of Use  --  Contact