Okay I am almost complete with this project but I need help on these two methods that I have, i can't figure out how to create these methods so that they work.

The method countNumberRolls(), what it is supposed to do is count the total number of times that a pair of dice were rolled, so for example we have the numbers 2 through 12 the possible die roll combinations, So it cycles through 100 rolls, it's supposed to count how many times dice 2 through 12 were rolled, within the 100 rolls? Does that make sense, For some reason with this method It doesn't print out anything.

The next problem I'm having is displayRolls, This is supposed to cycle through the 100 and then display each one that was counted, This only displays the last dice that was rolld.

I am then supposed to pass these through in the bottom through setRollCount from the hui class.

import java.util.Random;

import java.util.*;

public class Histogram

{

private Random randomGenerator;

private int[] hundredRolls = new int[100];

private int[] countRolls = new int [13];

/**

* The Histogram constructor gets a seed value for the

* random number generator.

*

* The constructor needs to create a HistogramUI object. You

* also need an array to keep track of the dice roll values.

*/

public Histogram( long seed )

{

randomGenerator = new Random(seed);

int r = randomGenerator.nextInt();

}

/**

* Simulates the rolling of two dies and stores them in an

* array named hundredRolls.

*/

private int rollDice()

{

int result = 0;

int roll = randomGenerator.nextInt(6) + 1;

int roll2 = randomGenerator.nextInt(6) + 1;

result = roll + roll2;

return result;

}

// problem here in this method, this is supposed to display each dice that was rolled

public int displayrolls()

{

int total = 0;

for (int i = 0; i < hundredRolls.length; i ++){

total = hundredRolls[i];

countRolls[total]++;

}

return total;

}

// This is supposed to display the total number of times the dice was rolled.

public int countNumberOfRolls()

{

int toCount = 0;

for(int i = 0; i < hundredRolls.length; i++){

for(int k = 0; k < countRolls.length; k++){

if(hundredRolls[i] == countRolls[k]){

toCount ++;

}

}

}

return toCount;

}

public int sumOfRolls()

{

int total = 0;

for(int i = 0; i < 100; i++){

hundredRolls[i] = rollDice();

total += hundredRolls[i];

}

return total;

}

public double getMean()

{

int total = 0;

int rolls = sumOfRolls();

for(int index = 0; index < rolls; index++){

total += rollDice();

}

return (double)total / (double)rolls;

}

/**

* This method needs to call the HistogramUI methods to set up and

* display a Histogram.

*/

public void displayHistogram()

{

HistogramUI histogram = new HistogramUI( "Dice" );

histogram.setMax(20);

// Pass the number of times that a particular dice roll happened. For example, the statement:

//histogram.setRollCount( 2, 10 );

//would tell the user interface to display a bar 10 units high for dice roll 2. You need to call this method for each die roll in the range 2 through 12 so that every bar in the histogram will get displayed.

histogram.setRollCount(displayRolls(),countNumberOfRolls());

histogram.setMean(getMean());

histogram.setMedian(3.2);

histogram.setMode("23");

histogram.setVisible();

}

}