Skip to content
Advertisement

How to get java to recognize a certain group of random integers

It’s slightly hard to explain but I’m making a basic system were it would have a random chance to output something else, I have a single integer that can be different, and need java to be able to know when this said integer is going to be 580-599. I’m Completely stuck and I’m new to java. (I’m not sure if the title is phrased properly) my code is:

JavaScript

I thought I could get the “random_int” to be recognized when it’s 580-599 to output something, please help me.

Advertisement

Answer

If you want to include 580 and 599 as part of that range, you can just use an if statement to check:

JavaScript

The && is known as a logical AND operator and we use it when we want to check if two conditions are both true in order to do something. In your case, these two conditions are the upper and lower bounds of the range.

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement