
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.security.SecureRandom;
import java.util.Random;

public class RealRandom {
 
	//reads from /dev/random
	//  entropy data
	
	DataInputStream in;
	
	//We would actually use this
	SecureRandom rng;
	
	public RealRandom() {
		try {
			in = new DataInputStream(new FileInputStream("/dev/random"));
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		}
	}
	
	//return a value from 0..1 (not including 1)
	public double nextDouble() {
		
		try {
			int value = in.readInt();
			return ((double)Math.abs(value))/Integer.MAX_VALUE;
		} catch (IOException e) {
			e.printStackTrace();
		}
		return 0;
	}
	
	//return an int between min and max (not including max)
	public int nextInt(int min, int max) {
		int range = max - min;
		
		try {
			int value = in.readInt();
			return Math.abs(value % range + min);
		} catch (IOException e) {
			e.printStackTrace();
		}
		return 0;
	}
	
	
	public static void main(String[] args) {
		RealRandom rand = new RealRandom();
		
		for(int i = 0; i < 10; i++) {
			System.out.printf("%10d", rand.nextInt(0, 100));
		}
		System.out.println();

		for(int i = 0; i < 10; i++) {
			System.out.printf("%10.6f", rand.nextDouble());
		}
		System.out.println("");
		
		for(int i = 0; i < 1050; i++) {
			if(i % 50 == 0)
				System.out.println();
			System.out.printf("%2d", rand.nextInt(0, 10));
		}

	}

}
