id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

srp4379@lausd.net 1-logicbasics > inEitherOf2Ranges
prev  |  next  |  chance

public boolean inEitherOf2Ranges(int number)

Given a number, return true if it is either of 2 non-overlapping ranges.
Range1: 32-50 OR Range2: 70-90.
Return false if it isn't.


public boolean inEitherOf2Ranges(int number) {
  boolean inRange1 = false;
  if (32 <= number && number <= 50) {
    inRange1 = true;
  }

  boolean inRange2 = false;
  if (70 <= number && number <= 90) {
    inRange2 = true;
  }
  
  boolean inEitherRange = false;
  if (inRange1 || inRange2) {
    inEitherRange = true;
  }
  return inEitherRange;
}

inEitherOf2Ranges(32) → true
inEitherOf2Ranges(50) → true
inEitherOf2Ranges(60) → false

...Save, Compile, Run (ctrl-enter)

public boolean inEitherOf2Ranges(int number) { }

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Java Help

Misc Code Practice

Difficulty: 1

Copyright Nick Parlante 2017 - privacy