
-----------------------------------
Prince Pwn
Tue Feb 09, 2010 3:11 pm

Dice Generator Probability
-----------------------------------
This application looks to be coded properly, but every time I run it, 1-4 "random" dice values are never landed on. Is this a bug with random and how long it takes to start at a new seed, or what?


/***********************************

    Program:    Question 7.17
    Date:       February 9, 2010

***********************************/

import java.util.Random;

public class Q717
{
    public static void main (String

-----------------------------------
DemonWasp
Tue Feb 09, 2010 4:02 pm

RE:Dice Generator Probability
-----------------------------------
You're creating a new instance of Random every iteration through the loop, which probably has something to do with it. Either initialize and use a single Random object for all rolls, or, if you need a new one each time for some reason, use SecureRandom() which gives cryptographically secure "true" random numbers.

-----------------------------------
Prince Pwn
Tue Feb 09, 2010 4:47 pm

RE:Dice Generator Probability
-----------------------------------
Thanks again, DemonWasp. Here's my final code:


/***********************************

    Program:    Question 7.17
    Date:       February 9, 2010

***********************************/

import java.util.Random;

public class Q717
{
    public static void main (String
