Throw of a die in Java

Posted by Arkapravo on Stack Overflow See other posts from Stack Overflow or by Arkapravo
Published on 2010-04-10T03:47:47Z Indexed on 2010/04/10 4:13 UTC
Read the original article Hit count: 410

Filed under:
|

The throw of a die is a popular program in Java,

public class Die {

    /*  This program simulates rolling a die */
    public static void main(String[] args) {
        int die;   // The number on the die.
        die = (int)(Math.random()*6 + 1);
        System.out.println (die);         
    } // end main()
} // end class

What I wish to do is make it repeat, 500 times. I have not been able to put this program into a loop of 500. I usually program in Python, thus I guess my Java has rusted !

Any help is most welcome !

© Stack Overflow or respective owner

Related posts about java

Related posts about beginner