15,558,869 members
1.00/5 (1 vote)
See more:
Use the variable x as you write this program. x will represent a positive integer. Write a program that determines if x is between 0 and 25 or between 75 and 100. If yes, print the message:_ is between 0 and 25 or 75 and 100, where the blank would be the value of x. The program should do nothing if the value of x does not fit into either range.

If x is 8, then the output would be: 8 is between 0 and 25 or 75 and 100.
If x is 80, then the output would be: 80 is between 0 and 25 or 75 and 100.
If x is 100, then the output would be: 100 is between 0 and 25 or 75 and 100.

What I have tried:

```Scanner as = new scanner();
int a = as.nextIn();

int[] x = {0 &&  25 && 75 && 100};

if (int x == 8)
System.out.println(x + " is between 0 and 25 or 75 and 100");

else if ( int x >=75)
System.out.println(x + " is between 0 and 25 or 75 and 100");<pre lang="Java"><pre lang="Java"><pre lang="Java">
```

else(int x=100)
System.out.println(x + " is between 0 and 25 or 75 and 100");
Posted
Updated 13-Apr-22 6:35am

## Solution 1

The following line is wrong, as it means nothing.
Java
```int[] x = {0 &&  25 && 75 && 100};
```

And why are you making a test for the value 8? Read the instructions again: check if the value entered is between 0 and 25, or between 75 and 100.

## Solution 2

Start by reading the question carefully - it's pretty explicit about what exactly it wants you to do, and you aren't really doing that at all.
And at some point you want a condition with AND and OR in it: Java Logical Operators with Examples - GeeksforGeeks[^] Read what they do, and then look at the example - it should give you the idea of what you need, if not the actual code to type in ...