Java tutorial
//package com.java2s; import java.util.Random; public class Main { public static int handleRange(int i1, int i2) { Random rand = new Random(); int result; int range; int loc; if (Double.valueOf(i1) > Double.valueOf(i2)) { range = (int) ((Double.valueOf(i1) * 100) - (Double.valueOf(i2) * 100)); loc = (int) (Double.valueOf(i2) * 100); } else { range = (int) ((Double.valueOf(i2) * 100) - (Double.valueOf(i1) * 100)); loc = (int) (Double.valueOf(i1) * 100); } result = (loc + rand.nextInt(range + 1)) / 100; return result; } public static int handleRange(String string, String splitter) { Random rand = new Random(); int result; int range; int loc; String[] splitString = string.split(splitter); if (getDouble(splitString[0], 0) > getDouble(splitString[1], 0)) { range = (int) ((getDouble(splitString[0], 0) * 100) - (getDouble(splitString[1], 0) * 100)); loc = (int) (getDouble(splitString[1], 0) * 100); } else { range = (int) ((getDouble(splitString[1], 0) * 100) - (getDouble(splitString[0], 0) * 100)); loc = (int) (getDouble(splitString[0], 0) * 100); } result = (loc + rand.nextInt(range + 1)) / 100; return result; } public static double getDouble(String string, double fallBack) { double d; try { d = Double.parseDouble(string); } catch (Exception e) { d = fallBack; } return d; } }