Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

Quick 10 points! How do I get a list of 40 random numbers between 0-100 in ready to program?

In the java program : Ready To Program how do I get a list of 40 random numbers between 0-100

4 Answers

Relevance
  • Anonymous
    1 decade ago
    Favorite Answer

    Have a look at the Java website

    Her is the direct link to the Help Centre

    http://java.com/en/download/help/index.xml

    Hope it helps

  • 1 decade ago

    I don't have any idea what Ready To Program means but here's how to generate a random integer between 0 and 100:

    Integer i;

    java.util.Random rand = new java.util.Random();

    i = rand.nextInt(101);

    Now, if you were to put the "i = rand.nextInt(101);" line inside a loop that iterates 40 times, you would generate 40 random numbers between 0 and 100. Of course, if you want to see the list, you'll need to print it out. Adding a call to one of java's print or println methods after the "i = ..." line, inside your "1 to 40" loop, you'd get your list.

    Source(s): javadoc java.util.Random
  • Anonymous
    1 decade ago

    I am not sure what "Ready To Program" is, but try something like this:

    Random rd = new Random(187654329);

    List<Integer> numbers = new ArrayList<Integer>();

    for (int a = 0; a < 40; a++) {

    int num = rd.nextInt(101);

    //optional output

    //System.out.println(num);

    numbers.add(num);

    }

  • ?
    Lv 4
    4 years ago

    the two one among those suggestions are incorrect yet shadowman's blunders is minor the nextInt(a hundred and one) will return values from 0 by way of a hundred, inclusive. What you rather need is: nextInt(a hundred) + a million which provides you with values from a million by way of a hundred, inclusive.

Still have questions? Get your answers by asking now.