random numbers


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: random numbers

  1. #1
    Steve Guest

    random numbers


    Hello

    I am stuck on a problem from a book I have it asks me to generate random
    numbers between 1 and 100 using the following
    Math.round(Math.random()*100);
    With a sential number to end the sequence

    I have no idea how to go about this as the book does not cover it..Can anybody
    help me with this

  2. #2
    emtinc Guest

    Re: random numbers


    The following book contains many basic examples, including the one you are
    looking for

    "Learn Java by Association with ...", www.techednet.com

    "Steve" <khalad@ozemail.com.au> wrote:
    >
    >Hello
    >
    >I am stuck on a problem from a book I have it asks me to generate random
    >numbers between 1 and 100 using the following
    > Math.round(Math.random()*100);
    >With a sential number to end the sequence
    >
    >I have no idea how to go about this as the book does not cover it..Can anybody
    >help me with this



  3. #3
    seun Guest

    Re: random numbers


    Hello emtinc,
    Why not try and change this line Math.round(Math.random()*100); to Math.round(Math.random()%101);.This
    should give you random numbers between less than 101(100 inclusive).
    Thanks,
    Seun


    "emtinc" <emtinc@hotmail.com> wrote:
    >
    >The following book contains many basic examples, including the one you are
    >looking for
    >
    >"Learn Java by Association with ...", www.techednet.com
    >
    >"Steve" <khalad@ozemail.com.au> wrote:
    >>
    >>Hello
    >>
    >>I am stuck on a problem from a book I have it asks me to generate random
    >>numbers between 1 and 100 using the following
    >> Math.round(Math.random()*100);
    >>With a sential number to end the sequence
    >>
    >>I have no idea how to go about this as the book does not cover it..Can

    anybody
    >>help me with this

    >



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center