The Artima Developer Community
Sponsored Link

Java Answers Forum
Random Number generator question.

1 reply on 1 page. Most recent reply: Jun 25, 2004 10:59 PM by Clay Dagler

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
Brooke Deats

Posts: 1
Nickname: zuul
Registered: Jun, 2004

Random Number generator question. Posted: Jun 25, 2004 1:23 PM
Reply to this message Reply
Advertisement
Okay, I'm very new to this, so forgive me if the question is a little elementary. I was wondering if a random number generator could be set up so the numbers it generates add up to a certain value. Thanks.


Clay Dagler

Posts: 21
Nickname: cdagler
Registered: Jul, 2003

Re: Random Number generator question. Posted: Jun 25, 2004 10:59 PM
Reply to this message Reply
> Okay, I'm very new to this, so forgive me if the question
> is a little elementary. I was wondering if a random number
> generator could be set up so the numbers it generates add
> up to a certain value. Thanks.

Is this what you want?

int certainValue = 173; //just an example.
int[] someNums;
storeRandomNums(someNums);
int lastNum = certainValue-sumOf(someNums);

The random numbers you want are someNums[0], ..., someNums[someNums.length-1], lastNum.

Flat View: This topic has 1 reply on 1 page
Topic: Processing large files suggestions Previous Topic   Next Topic Topic: Table does not get updated

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use