import java.util.*;

/**
 * Random Example class - illustrate use of Random class
 * for pseudorandom number generation
 *
 * @author Suzanne Balik, 4 Oct 2004
 */
public class RandomExample {
  
  public static void main(String[] args) {
    
    //Create a random number generator using the system time
    //in millis as the "seed"
    Random generator = new Random();
      
    int NUMBER_OF_TOSSES = 10;
    int MAX = 2;
    
    System.out.println
    ("\nWith DIFFERENT seed each time program is run"); 
    for (int i = 0; i < NUMBER_OF_TOSSES; i++) {
      
      int value = generator.nextInt(MAX);
      System.out.println
        (i + ". " +  (value == 0 ? "Heads" : "Tails"));
    }
    
    //Try it again using a "seed"
    generator.setSeed(500);
    System.out.println
        ("\nWith SAME seed each time program is run"); 
    for (int i = 0; i < NUMBER_OF_TOSSES; i++) {
      
      int value = generator.nextInt(MAX);
      System.out.println(i + ". " + (value == 0 ? "Heads" : "Tails"));
    }
  }
}