Java tutorial
//package com.java2s; import java.util.Random; public class Main { public static int getRandomNumber(int max) { if (max <= 0) return 0; int random = (int) (Math.random() * max + 1); return random; } public static double getRandomNumber(double start, double end) { double random = new Random().nextDouble(); double result = start + (random * (end - start)); return result; } }