Interval

Report a typo

Given an integer as an input, print True if its value falls within the interval (−15,12]∪(14,17)∪[19,+∞). Otherwise, print False.

Keep in mind,

  • numbers denoted with a parenthesis, either ( or ) are exclusive;

  • numbers denoted with a square bracket, either [ or ] are inclusive.

Hint

Your program should return True, if the value is greater than -15 and less than or equal to 12, or greater than 14 and less than 17, or greater than or equal to 19.

Sample Input 1:

20

Sample Output 1:

True

Sample Input 2:

-20

Sample Output 2:

False
Write a program in Java 17
import java.util.Scanner;

class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
// start coding here
}
}

Create a free account to access the full topic