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