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

 

jebbert@volusia.k12.fl.us > inDomain
prev  |  next  |  chance

Your goal is to determine if an x-value is in the given domain. Write a mehtod with two input parameters. The first parameter is x, which is the x-value to test. The second parameter is domain which is an array of integers. This array indicates intervals that are in the domain (end-points included). For example, the array {4,5,17,19} indicates a domain of [4,5] [17,19]. The array will have an even number of elements and the intervals will not overlap. The intervals will not be listed in any particular order so {4,5,17,19} indicates the same domain as {17,19,4,5}. Return true if the x-value is in the domain. Return false otherwise. Note that the domain only has integer end-points, but the x-value will be a double. The x-value will be somewhere between the lowest possible integer and the greatest possible integer. The domain will contain at least one interval.


inDomain(30.0, [-3, 2, 8, 12, 30, 300]) → true
inDomain(30.04, [-5, 5, 8, 14, 30, 300]) → true
inDomain(298.0, [-7, 250, 800, 1200, 3000, 30000]) → false

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

public boolean inDomain(double x, int[] domain) { }

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: 420

Copyright Nick Parlante 2017 - privacy