Random number between 1 & 16?

Hello all.  I need to create a variable that holds a random number  between 1 & 16.  Any idea how I can do this?  This is the way the  variable looks right now:
var randomTurkey:Number = Math.floor(Math.random()*100);

Never mind, I got it.  Thanks!

Similar Messages

  • Random Number between 10 and 30

    I'm just curious how to generate a random number between 10 and 30. I know I use the Math.Random function, but I'm not certain how to do it when the starting number is >1 (i.e. 1 to 30). Thanks.

    Random Number in an Interval:
    ((int) (randomGeneratedNumber * difference)) + startIndex + 1
    * randomGeneratedNumber - Number >= 0 and <1
    * difference: To generate between 10 and 30, (30 -10 = 20)
    * startIndex: In this example, 10
    * +1: Neccesary adjustment.
    Example:
    ((int)(randomGeneratedNumber * 20)) + 10 + 1
    PD. Int cast it's to generate int numbers, so it's optional.

  • Get a random number between 2 numbers?

    Are their any classes which can produce a random number within a set of numbers i specify?
    If their are no predefined java classes then it doesnt matter.
    Thanks

    No as far as I know, but its easy to create one:
    double low_Limit, super_Limit;
    double interval = super_Limit - low_Limit;
    //Generate a random number between 0 and 1, with a Java satandard class
    double random_number = Math.random();
    //Now we generate a random numbre between 0 and intervalo:
    random_number = random_number * intervalo;
    // now we generate a random number between low_Limit super_Limit:
    random_number = random_number + low_Limit;
    //done :)
    Abraham.

  • How to Build a VI that generates a random number between 1 and 80 ....Help!!!!

    Build a VI that generates a random number between 1 and 80 
    Divides the random number by a number specified in the front panel.
    If the inputted number is zero, the VI program should turn on a LED in the front-panel to indicate a divide by zero error.
    Solved!
    Go to Solution.

    One quick question Edward, was the answer just in time for your monday morning class.
    Ton
    Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
    Nederlandse LabVIEW user groep www.lvug.nl
    My LabVIEW Ideas
    LabVIEW, programming like it should be!

  • How I get random number between 1 and int number ?

    how can I get random number between 1 and int number
    like between 1 and 10 etc.
    10x

    Use the nextFloat() method of the Random class, this returns a random number between 0.0 and 1.0. To get and integer range from that multiply the return value of that method call by the integer range you need (in this case 10), and add the starting number you want returned in the range (1 in this case). The code below works for numbers 1-10.
    Random r = new Random();
    int x = (int)(r.nextFloat()*10) +1;

  • Random number between a range

    hi all!
    how can i find random number between an specified range
    for example b/w 5-10
    thanks to all
    smh

    Here's a practical instance;-import java.util.Random; // Maybe you forgot this
    public class ImplementRandom {
      public void getRandom(int from, int range) {
         int newRandom;
         Random random = new Random(); 
         newRandom = from + random.nextInt(range);
         System.out.print(newRandom); 
      public static void main(String[] args) {
         ImplementRandom IC = new ImplementRandom();
         IC.getRandom(1, 100);
    }Actually that uses public void rather than public int as you cannot reference a non-static (return-type) method from a static context.

  • Random number between .2 and 1

    How do I generate a random number between 0.2 and 1.0

    ... or for - eg for 2 decimal places try this;-
    java.util.Random rand = new java.util.Random();
    int i = 20 + rand.nextInt(80);
    double d=(double)i;
    d /=100;

  • Re: Generating a random number between 1-10;

    How do I generate a number between 1-20? I saw how to on this forum once, but I can't find it, and I don't have much time to look. Sorry for any inconvinience. What I want to do is assign to the variable x the random number.
    Thanks.
    Virum

    Random rnd = new Random();
    int x = rnd.nextInt(20)+1;

  • Random number between a range fix

    Hello
    I need to place an object on the stage.x randomly but not going .
    The stage is 1024 pixel and the object 726. I do the following, it works ok but sometimes some part of the object goes of the stage. Could you tell me what I do wrong?
    menucenter=Stage.width-_root.object._width;
    _root.object._x=Math.floor(Math.random() * (menucenter - 0)) - 0;
    Thank you
    George

    if the object has reg point at it's left edge use:
    _root.object._x=Math.random()*menucenter;

  • Is there any way to generate random number in CPO

    Requirement : -
    > I want  to generate a random number from set of 1-9 numbers .is there any way in cpo ?
    Thanks
    Siva

    I created a process that uses 3 steps, all of which happen inside the engine rather than having to span out to a script, so it runs a lot faster.
    Technically, it's pseudo-random...
    Predefine Output Variable "Random Number" as type "Numeric"
    Step 1:  Format Date
      Format string: fffffff 
        (that's seven lower-case letters "f")
      Original date: [Process.Start Time]
    Step 2: Format Date
      Format string: ff\0\0\0\0\0
      Original date: [Process Start Time]
    Step 3: Set Variable
      Variable to update: [Process.Variables.Output.Random Number]
      New value: ([Workflow.Format Date.Formatted Date]-[Workflow.Format Date (2).Formatted Date])/100000
    This returns a basically random number between 0 and 1 (so you can mulitply it by your maximum value) based on the numeric fraction of a second of the start time of the process.

  • SsRandom or another way to get a random number

    In iDocScript, I need to get a random number between 0 and 4, or it could be between 1 and 5. I found ssRandom, but am unsure how to use that number to get the range I want. Any other ways or advice?

    I found the answer, below is some iDocScript for generating random numbers.
    [!--$randomIndex = ssRandom()--]
    [!--$if randomIndex lt 0--]
    [!--$randomIndex = randomIndex * (-1)--]
    [!--$endif--]
    [!--$randomIndex = randomIndex % 5--];

  • How can you generate a random number?

    Say I have a timer, and I need it to choose a random number between 100 and 1000. How would I do that?
         timer.delay(***RANDOM***);Thanks!

    I have this, and it's working for me:
    int j = rand.nextInt(500);
    But I actually want it to generate a random number between 100 and 500, not 0 and 500. How could I do this?
    ~Dac

  • Need Random "Number" Generation

    Hi...
    Need an easy way to generate a random "number" from an ABAP program... that is a combination of numbers and alphabetic characters.
    Is there a Function Module I did not find?
    Currently using Function module 'QF05_RANDOM_INTEGER' but this only generates a number.
    Thanks for your insights !
    Dave...

    Hi,
    I wrote a little method to generate a random number between 1 and 100 (can be modified to allow bigger range of numbers).  The code is below...  It basically gets a timestamp into a field of type timestampl (note the letter L at the end of the type).  The method signature consists of a single returning parameter called RANDOM_NUMBER (type I).  After much testing, the random sequence of numbers is extremely varied (even without a seed).
    Since 'QF05_RANDOM_INTEGER' already exists, then my method is not needed here, but I thought I'd include it in this thread since the topic was brought up.
    Cheers,
    James G.
    METHOD GENERATE_RANDOM_NUMBER .
      DATA:
        delay_cnt     TYPE i,
        lc_ran_seed   TYPE p,
        lc_time       TYPE timestampl,
        ran_num       TYPE p DECIMALS 7.
    * Get the long time stamp (nano second level)
      GET TIME STAMP FIELD lc_time.
    * Get the decimal part of the time stamp and shift it so that only the
    * last decimal values are used (i.e. the smallest unit of time)
      ran_num = frac( lc_time ).
      ran_num = ran_num * 10000.
    * Perform a delay with a varying length of time so that the next time
    * stamp will be more "random" if the method is called multiple times
    * (e.g. if called in a do loop to generate many random numbers)
      delay_cnt = ran_num * 2.
      DO delay_cnt TIMES. ENDDO.
    * Get the decimal part of the shifted time stamp, multiply it by 100 to
    * shift it to the left 2 decimal places, and add 1 to the result.
      ran_num = frac( ran_num ).
      lc_ran_seed = ( ran_num * 100 ) + 1.
      random_number = lc_ran_seed.
    * If the number generated is not between 1 and 100, then try again.
      IF random_number IS INITIAL OR random_number < 1
                                  OR random_number > 100.
        CALL METHOD me->generate_random_number
          RECEIVING
            random_number = random_number.
      ENDIF.
    ENDMETHOD.

  • Random Number Generator issues

    Ok so I have an issue. I'm supposed to create a GUI app that has a frame that contains both a button and a textfield. When the button is pressed then a random number between 1 and 10 should appear in the textfield. I've got an illegal start of expression on line 49 which is the last private void...
    So what have I done wrong?
    * randomnumber.java
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.util.Random;
    public class randomnumber extends JFrame
         Random randomObject = new Random();
      // declare controls used
      static JButton startButton = new JButton();
      static JTextField startTextField = new JTextField();
      public static void main(String args[])
        new randomnumber().show();
      public randomnumber()
        // frame constructor
        setTitle("Random Number Generator");
        getContentPane().setLayout(new GridBagLayout());
        // add controls
        GridBagConstraints gridConstraints = new GridBagConstraints();
        startButton.setText("Generate a Number");
        gridConstraints.gridx = 0;
        gridConstraints.gridy = 0;
        getContentPane().add(startButton, gridConstraints);
        startButton.addActionListener(new ActionListener()
          public void actionPerformed(ActionEvent e)
            startButtonActionPerformed(e);
        startTextField.setText("");
        startTextField.setColumns(15);
        gridConstraints.gridx = 2;
        gridConstraints.gridy = 0;
        getContentPane().add(startTextField, new GridBagConstraints());
      private void startButtonActionPerformed(ActionEvent e)
        myInt = randomObject.nextInt(11);
        startTextField.setText(String.valueOf(myInt));
    }Edited by: Hessmix on Oct 17, 2007 6:15 PM

    public randomnumber()
        // frame constructor
        setTitle("Random Number Generator");
        getContentPane().setLayout(new GridBagLayout());
        // add controls
        GridBagConstraints gridConstraints = new GridBagConstraints();
        startButton.setText("Generate a Number");
        gridConstraints.gridx = 0;
        gridConstraints.gridy = 0;
        getContentPane().add(startButton, gridConstraints);
        startButton.addActionListener(new ActionListener()
          public void actionPerformed(ActionEvent e)
            startButtonActionPerformed(e);
        startTextField.setText("");
        startTextField.setColumns(15);
        gridConstraints.gridx = 2;
        gridConstraints.gridy = 0;
        getContentPane().add(startTextField, new GridBagConstraints());
      }//<< Add a brace here
      private void startButtonActionPerformed(ActionEvent e)
        myInt = randomObject.nextInt(11);
        startTextField.setText(String.valueOf(myInt));
    }Did you add that brace?

  • Defining a lower boundery for a random number Generator

    Hi,
    I am using the code:
    Random rand = new Random();
    int x = rand.nextInt(50);
    to generate a random number between 0 and 49
    However I now need to only select a number between 20 and 49
    Is there any way to give the random number generator a lower boundery as well as an upper boundery ??
    Thank you
    Craig

    example:int x = rand.nextInt(30) + 20;Will generate a number between 20 and 49.

Maybe you are looking for