DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
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

    >



Bookmarks

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


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links