Java Random Int randomNumber(int lower_bound, int higher_bound)

Here you can find the source of randomNumber(int lower_bound, int higher_bound)

Description

Random number.

License

Open Source License

Parameter

Parameter Description
lower_bound the lower_bound
higher_bound the higher_bound

Return

the int

Declaration

public static int randomNumber(int lower_bound, int higher_bound) 

Method Source Code

//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;
    }
}

Related

  1. randomMatrix(int x, int y)
  2. randomModuleName(int count)
  3. randomNum(int n)
  4. randomNum(int number)
  5. randomNumber(int lower, int upper)
  6. randomNumber(int min, int max)
  7. randomNumber(int minimum, int maximum)
  8. randomNumberBetweenIntervals(int min, int max)
  9. randomNumberWithinRange(int low, int high)