fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. int minimum=10;
  13. int maximum=25;
  14. int randomNum;
  15. int less=0,more=0, inside =0;
  16. for(int i =0 ;i<10000000;i++){
  17. randomNum = minimum + (int)(Math.random() * (maximum - minimum));
  18. if(randomNum < minimum)
  19. less++;
  20. else if(randomNum >maximum)
  21. more++;
  22. else
  23. inside++;
  24. }
  25. System.out.println("less = " + less);
  26. System.out.println("more = " + more);
  27. System.out.println("inside = " + inside);
  28.  
  29. }
  30. }
Success #stdin #stdout 0.26s 28176KB
stdin
Standard input is empty
stdout
less = 0
more = 0
inside = 10000000