generate random number using math random in java

Solutions on MaxInterview for generate random number using math random in java by the best coders in the world

showing results for - "generate random number using math random in java"
Delores
15 Aug 2020
1class GenerateRandom {
2    public static void main( String args[] ) {
3      int min = 50;
4      int max = 100;
5        
6      //Generate random int value from 50 to 100 
7      System.out.println("Random value in int from "+min+" to "+max+ ":");
8      int random_int = (int)Math.floor(Math.random()*(max-min+1)+min);
9      System.out.println(random_int);
10    }
11}