How generate a random number that is between 0 and 15! (0-15)

how generate a random number that is between 0 and 15 ??? (0-15)
pls tell me, thx!!!!!!!!!!!!!!!!!

import java.util.Random;
Random r = new Random();
int mynumber = r.nextInt()%16;
For (2^1)-1 number use:
-> int mynumber = r.nextInt()&15; // speedup

Similar Messages

  • 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 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

  • How to generate a random number with at least 6 digits?

    Hi all,
    All is in the question. :-)
    I would like to generate a random number but the function "random
    number" in Labview isn't accurate enough.
    Do you know an algorithm to generate a random number of 6 or more
    digit?
    Thanks,
    PF

    Hi PF,
    It's simple. Use 2 random number functions in the same process. Now you
    should have 2 distinct random numbers that have the same accuracy. Let's say
    LV gives accuracy up to the thousandth (0.XXX), now if you divide one number
    by 1000 and then add to the other number you should then have something like
    0.XXXXXX. Actually, LV random number function can give up to about 17 digits
    (decimal). If you are looking for more digits (>17 digits), the idea above
    may not work, then the last thing you may want try is to generate two or
    three random numbers then convert all these decimal numbers to fractional
    strings chop off the 0 and dot then concatinate them together. After all
    it's still a random number. How many digits do you want to get? Make sure
    the indicators acce
    pt that many digits?
    Good luck
    Louis.
    P-F wrote in message
    news:[email protected]..
    > Hi all,
    >
    > All is in the question. :-)
    >
    > I would like to generate a random number but the function "random
    > number" in Labview isn't accurate enough.
    >
    > Do you know an algorithm to generate a random number of 6 or more
    > digit?
    >
    > Thanks,
    >
    > PF

  • Generate a random number

    How do you generate a random number?

    You can also check out Math.random() which returns a
    double value between [0..1)You could, depending on your needs, but if you do want ints then you're better off using nextInt from java.util.Random, as outlined by the author here:
    http://java.sun.com/docs/books/effective/excursion-random.html
    (and what was wrong with 125?! I thought that was a perfectly fine random number...)

  • Generate a random number and make it STAY after "save"

    I searched around this forum and found that I can use this code to generate a random number:
    //this.rawValue = Math.round(Math.random() * 1000000);
    Works great. only problem is, once I practice on the "real" form and save, close, and reopen - it changes the random number every time. I need to figure out a way to make it save the 1st number it generates when someone opens the form and types info in it....then they save and close, etc.
    Can anyone help me? Thanks!!

    Example steps:
    1. Add a hidden field to the same subform with name 'hiddenField'.
    2. First time you open 'hiddenField' rawValue will be null.
    3. where ever you run the code to generate random number use scenario like this.
    if (hiddenField.isNull) {
    this.rawValue = Math.round(Math.random() * 1000000);
    }else {
    this.rawValue = hiddenField.rawValue;
    Hope this thelps.
    SekharN

  • How can i get number of days between two dates represented by two dates?

    how can i get number of days between two dates represented by two date objects. One is java.sql.Date, the other is java.util.Date?

    tej_222 wrote:
    But how do I do that conversion. from java.sql.date and java.util.date to calender?
    -thanks for the quick response.You may find the following utility code samples useful:
    [http://balusc.blogspot.com/2007/09/calendarutil.html]
    [http://balusc.blogspot.com/2007/09/dateutil.html]
    ganeshmb wrote:
    (date1.getTime() - date2.getTime())/(1000*60*60*24) should do.
    getTime returns millsecond value of date object and the difference divided by no of milliseconds in a day should fetch you the difference in terms of days.This doesn't respect the DST. Use java.util.Calendar.

  • How to sort random number without the used of order by

    Hi ,
    how should 5 random number be sorted without the use of order by in PLSQL
    eg.
    id amount
    1 2
    2 9
    3 3
    4 5
    5 7
    Edited by: sake1 on 1-dec-2010 8:16

    I used Altavista and found one example, how does it look?
    DECLARE
      /* there is no built array in oracle, you must declare
      your own */
      TYPE Numarray IS TABLE OF NUMBER INDEX BY BINARY_INTEGER;
      /* the array of numbers - using assoc array because I can start
      with zero like traditional arrays */
      Nums Numarray;
      n NUMBER := 0;
      Temp NUMBER;
    BEGIN
      /* load up the array, put 20 random values in the array,
      in array indicies 0 to 19 */
      FOR i IN 0 .. 19
       LOOP
        Nums(i) :=  Round(Dbms_Random.Value(1, 1000));
      END LOOP;
      /* get the array size */
      n :=  Nums.Count();
      /* display the unsorted values - loop through the whole array and
      print out the values */
      Dbms_Output.Put_Line('unsorted:');
      FOR i IN Nums.First .. Nums.Last LOOP
        Dbms_Output.Put_Line(Nums(i));
      END LOOP;
      /* bubble sort - using two loops, compare each value with the one
      after it
      if the one after the current one is smaller , then
      switch their locations in the array, this is just like standard
      bubble sorts
      in other languages. The only real diff is the syntax.
      FOR i IN 0 .. n - 1 LOOP
        FOR j IN 0 .. n - (i + 1) - 1 LOOP
          IF (Nums(j) > Nums(j + 1)) THEN
            Temp := Nums(j);
            Nums(j) :=  Nums(j + 1);
            Nums(j + 1) :=  Temp;
          END IF;
        END LOOP;
      END LOOP;
      /* display the values sorted */
      Dbms_Output.Put_Line('sorted');
      FOR i IN Nums.First .. Nums.Last LOOP
        Dbms_Output.Put_Line(Chr(9) || Nums(i));
      END LOOP;
    END;
    unsorted:
    155
    909
    795
    977
    942
    214
    105
    269
    283
    820
    108
    594
    784
    921
    856
    736
    802
    457
    951
    411
    sorted
         105
         108
         155
         214
         269
         283
         411
         457
         594
         736
         784
         795
         802
         820
         856
         909
         921
         942
         951
         977
    */In the code the first comment is wrong actually i think, that one:
    "there is no built array in oracle, you must declare your own"
    I remember there were some system collection-types, if i'm not mixing with something, i remember there was some kind of such but they were un-documented ones, so we can juridically say that the comment in the code was still correct.

  • How to release batch number that's allocated in a "closed' sales order

    Hi,
    Does anyone knows how to release batch number that's allocated in a "closed" sales order? I'm using SAP B1 2005B PL42.
    This batch number 'A' was allocated in the sales order. However, when this sales order is copied to multiple delivery orders, one of the delivery order's batch number is changed to another batch number 'B'. The sales order had changed status to "closed" as full quantity is copied to Delivery orders. But from the batch number trans. report, the remaining quantity of batch number A is still "allocated" (I think due to bug in SAP B1) although the sales order is closed.
    Please help. Thanks!
    regards,
    sianghing

    Hi Suda,
    Thanks for reply. But I realize that batch number allocation in sales order is a hard allocation. We cannot use batch number quantity allocated in that closed sales order into another Sales Order or Delivery Order anymore.
    Thanks,

  • How do i get number of days between 2 dates?

    How do i get number of days between 2 dates?
    and the result must be in int.
    for example
    Ex. startdate: 2006-06-01 enddate: 2006-06-30 and the result is: 30
    how to do so? thx

    mel
    Iv'e used this method. It assumes startdate,enddate and days have been defined before but you could pass them as args.
    void days()
        try
          Date d1 = DateFormat.getDateInstance().parse(startdate);
          Date d2 = DateFormat.getDateInstance().parse(enddate);
          long days = (d2.getTime()-d1.getTime())/1000/60/60/24;
          days = ""+days;
        catch (ParseException e)
          System.out.println("Invalid date format");
      }It actually gets the duration in ms and divides down to days.
    Regards
    Chris

  • How  can I get number of days between 2 dates ?

    How can I get number of days between 2 dates ?
    Give me answer as soon as possible.....

    Mukesh_Prajapat wrote:
    How can I get number of days between 2 dates ?
    Give me answer as soon as possible.....Is google broken again?
    [How To Ask Questions The Smart Way|http://www.catb.org/~esr/faqs/smart-questions.html]

  • When i Place a PSD in Indesign it comes in at 200+% while the image frame is considerably smaller. How do i place so that the image and image frame match?

    When i Place a PSD in Indesign it comes in at 200+% while the image frame is considerably smaller. How do i place so that the image and image frame match?

    Peter,
    The screenshots tell you everything.
    The second one tells you how the image frame is automatically set up after a one-click place. It's the blue stroked rectangle with the eight control points at each corner and mid-way along the line. This image frame is generated at a proportionally correct height and width for the image it contains.
    Now, if you look at the third screenshot (click on it to see it at a larger size), you will see I've used the direct selection tool (white arrow) to click on the image within the image frame. This CLEARLY shows the image (within the image frame) is substantially larger than the frame generated to contain it. This is indicated by the yellow stroked rectangle with the eight control points at each corner and mid-way along the line.
    Notice that the blue and yellow rectangles are vastly different sizes.
    In InDesign CS5.5, when i clicked to place the image, the image would fit perfectly within its image frame. the blue and yellow rectangles would match.
    I had no need to go click on the proportional fill and centre buttons like i need to do now in CC.
    I have a keyboard shortcut to place. I can't do File > Place for the amount of images i need to place.
    So to reiterate: How do i place an image so that the image and image frame match?

  • How do I create buttons that once clicked and un clicked, alter an image? ...

    How do I create buttons that once clicked and un clicked, alter an image?
    So for example if I imported a psd file into Muse with 5 layers, could i create 5 buttons which, when clicked, each individually took off and added 1 layer?
    Basically this should make what i'm trying to say clear (when it's loaded click the arrow and you'll see): http://lust.nl/lustArchive/noordzee/noordzee.html
    Appreciate any help

    Hi Joe,
    Please use this option to hide the target on click - http://prntscr.com/3plqn0
    - Abhishek Maurya

  • How to deactivate one pc (that's broke) and activate my new pc

    how to deactivate one pc (that's broke) and activate my new pc

    Remove license on a computer http://forums.adobe.com/thread/1442423?tstart=0 may help
    -http://helpx.adobe.com/x-productkb/policy-pricing/error-maxium-acitvation-exceeded.html

  • How can I delete albums that I created and imported photos into on my iPhone4

    How can I delete albums that I created and imported photos into on my iPhone4

    If you synced the Photos from your computer to your phone, you have to unsync the pictures via iTunes.
    Summary Pane > Photos > Uncheck "Sync Photos from ..."

Maybe you are looking for

  • After trying to upgrade my iPhone to 3.0, it now doesn't have any service.

    I have the 1st gen iPhone, and tried to update to 3.0 and now I keep getting error codes on iTunes saying that there is an unknown error occured with iTunes, to try again later. Now my phone has no service and can only be used in emergency mode. In t

  • Schedule Manager in BOXI 3.1 - ScheduleManager.xml

    Hi, I would like to use the Schedule Manager in BOXI 3.1 I have downloaded the software from [http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/80af7965-8bdf-2b10-fa94-bb21833f3db8] I have followed the steps outlined in: [http://busi

  • JVM Error 102

    My phone has got a white screen with JVM Error 102 showing.  I have tried rebooting, taking battery out and leaving etc but not worked.  Apparently I can link up my phone using usb to laptop and do a fix but I am unsure how to go about this.  Can any

  • Web interface to config PIX

    IS there any web interface to config PIX?? Thx ^^

  • Tab Control Visual Basic

    Hi Good People I have A form With 2 Tab Controls, tabcontrol (1) at the top of the screen, tabcontrol (2) at the bottom of the screen. On Tab Control (1), I have a tabPage1 etc... And when I click on TabPage1, I would like to open a tabPage on the Ta