Welcome to the Java Programming Forums

The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Help With Code?

  1. #1
    Junior Member
    Join Date
    Oct 2013
    Caldwell Idaho
    Thanked 0 Times in 0 Posts

    Default Help With Code?

    So I'm trying to slightly alter the following Dice Class and Driver

    import javax.swing.JOptionPane;
    public class DiceExperiment{
    public static void main(String[] args){
    String casino=
    JOptionPane.showInputDialog("enter a toss count");
    int tosses=Integer.parseInt(casino);
    Dice d=new Dice();

    public class Dice{
    private int[] scoreboard=new int[13];
    public Dice(){

    public void initializeScoreboard(){
    for(int j=0;j<13;j++)scoreboard[j]=0;

    public int tossDie(){
    return (1+ (int)(6*Math.random()));

    public int throwDice(){

    public void multiToss(int tossCount){
    int score;
    for(int j=0;j<tossCount;j++){

    public int[] getScoreboard(){return scoreboard;}

    public void displayScoreboard(){
    for(int j=2;j<13;j++)
    System.out.println("toss of "+ j + " " + scoreboard[j]);
    System.out.println("toss count:");


    So this code rolls a pair of dice a number of times (# of times read from imput pane) and then reports how many times each total resulted from the rolls. I want to alter it so I enter a number into the pane and the dice continue to be rolled until each possible value of the dice throws (2,3,4,5....12) is reached at least the entered number of times. Poor description I know but heres a sample of what I want for an output...

    on the input 15
    2 15
    3 45
    4 58
    5 66
    6 93
    7 110
    8 96
    9 70
    10 47
    11 32
    12 19
    toss count: 651

    Any Help is appreciated!

  2. #2
    Grand Poobah
    Join Date
    Mar 2011
    My Mood
    Thanked 167 Times in 158 Posts

    Default Re: Help With Code?

    That is the worst posting of code ever. Use code tags in future.
    Improving the world one idiot at a time!

Similar Threads

  1. Replies: 3
    Last Post: April 27th, 2013, 07:19 AM
  2. Replies: 4
    Last Post: January 24th, 2013, 10:20 AM
  3. Replies: 7
    Last Post: January 24th, 2013, 09:41 AM
  4. Replies: 5
    Last Post: November 14th, 2012, 09:47 AM
  5. Replies: 3
    Last Post: September 3rd, 2012, 11:36 AM