Java tutorial
//package com.java2s; import java.util.Random; public class Main { public static float genRand(float min, float max) { return (float) Math.random() * (max - min) + min; } public static int genRand(int min, int max) { return (new Random()).nextInt(max) % (max - min + 1) + min; } }