random numbers

 DevX Home Today's Headlines   Articles Archive   Tip Bank   Forums

# Thread: random numbers

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

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

 FAQ Latest Articles Java .NET XML Database Enterprise
 Questions? Contact us. C++ Web Development Wireless Latest Tips Open Source