
Please How do I generate a program that gives me random integer from 115 to 250? Using java.util.random. Thank you very much!

Hi Friend,
Try the following code:
import java.util.*;
public final class RandomNumberBetweenTwoIntegers {
public static final void main(String[] args){
int min = 115;
int max = 250;
Random random = new Random();
long range = (long)max - (long)min + 1;
long fraction = (long)(range * random.nextDouble());
int randomNumber = (int)(fraction + min);
System.out.println(randomNumber);
}
}
Thanks
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.