import java.util.Random; public class ExampleRandomClassDemo { public static void main(String args[ ]) { boolean b; int i; int iRange; int n = 21; long l; float f; double d; int index; Random mystery = new Random( ); System.out.println ("5 random booleans: "); for(index=0;index<5;index++) { b= mystery.nextBoolean(); System.out.print (b +" "); } System.out.println ("\n5 random integers: "); for(index=0;index<5;index++) { i= mystery.nextInt(); System.out.print (i +" "); } System.out.println ("\n5 random integers within a range 0-20 (n=21): "); for(index=0;index<5;index++) { iRange= mystery.nextInt(n); System.out.print (iRange +" "); } System.out.println ("\n5 random integers within a range 0-9, excludes 10, as random generatesgreater than or equal to 0.0 and less than 1.0: "); for(index=0;index<5;index++) { iRange= (int)(Math.random() * 10); System.out.print (iRange +" "); } System.out.println ("\n5 random longs: "); for(index=0;index<5;index++) { l= mystery.nextLong(); System.out.print (l +" "); } System.out.println ("\n5 random floats: "); for(index=0;index<5;index++) { f= mystery.nextFloat(); System.out.print (f +" "); } System.out.println ("\n5 random doubles: "); for(index=0;index<5;index++) { d = mystery.nextDouble(); System.out.print (d +" "); } } //closing main method } //closing class header