Here you can find the source of randomNumber(int lower_bound, int higher_bound)
Parameter | Description |
---|---|
lower_bound | the lower_bound |
higher_bound | the higher_bound |
public static int randomNumber(int lower_bound, int higher_bound)
//package com.java2s; /**// ww w .j a v a 2 s. c o m * File name: QuestionsUtils.java * Version: 1.0 * Date: 26/3/2015 13:44:01 * Author: Itop1 * Copyright: Copyright 200X Itop1 * * This file is part of Math Attack. * * Math Attack is free software: you can redistribute it * and/or modify it under the terms of the GNU General * Public License as published by the Free Software * Foundation, either version 3 of the License, * or (at your option) any later version. * * Math Attack is distributed in the hope that it will * be useful, but WITHOUT ANY WARRANTY; without even * the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public * License for more details. * * You should have received a copy of the GNU General * Public License along with Math Attack. If not, see * http://www.gnu.org/licenses/. */ public class Main { /** * Random number. * * @param lower_bound the lower_bound * @param higher_bound the higher_bound * @return the int */ public static int randomNumber(int lower_bound, int higher_bound) { // A random integer value in the range [Lower_bound, Higher_bound] // Lower_bound + (int)(Math.random() * ((Higher_bound - Lower_bound) + 1)) int random_number = lower_bound + (int) (Math.random() * ((higher_bound - lower_bound) + 1)); return random_number; } }