/**
 * A good way to create a method    
 *
 * Create a random number generator method
 * Pass it a minimum and a maximum value
 * Get back a random number between those values
 *
 */

public class Rand1
{
    /**
     * main method 
     */

    public static void main (String[ ] args)
    {        
        int num;

        num = getRandom(0,5);                   //random number from 0 to 5
        System.out.println(num);

        num = getRandom(1,6);                   //random number from 1 to 6
        System.out.println(num);

        num = Rand1.getRandom(11,16);           //Calling the method using  
        System.out.println(num);                //class name 

        int from = 10;
        int to   = 20;

        num = getRandom(from, to);              //random number from 10 to 20
        System.out.println(num);

        System.out.println(getRandom(-10,10));  //random number from -10 to 10
    }


    /**
     * A random number generator method
     *
     * @param  min   - type int - random number minimum value
     * @param  max   - type int - random number maximum value
     * @return rand  - type int - the generator random number
     */

    static int getRandom(int min, int max)              //get min value & max value
    {
        int rand;                                       //create a local variable
        rand = (int) (Math.random( ) * (max-min+1));    //random dist over max-min
        rand = rand + min;                              //add the minimum value
        return (rand);                                  //return the random number
    }
}