dice rolling occurences
Could someone help me a little problem i am having with the double that appears most, I already have the occurences showing and a histogram but am unsure as to how to display the most frequent double(s), my code so far is:
import cs1.*;
import java.util.*;
publicclass TestDice
{
publicstaticvoid p(String s)
{
System.out.print(s);
}
publicstaticvoid main(String[] args)
{
PairOfDie dice;
int noRolls,x,doubles=0;
int [] dubs;
dice =new PairOfDie();
dubs =newint[6];
p("\n\n");
for (noRolls=0; noRolls < 1000; noRolls++)
{
dice.roll();
p("" + dice.getDice1() +"," + dice.getDice2() +"");
for (x=0;x<6;x++)
{
if(dice.getDice1() == (x+1) && dice.getDice2() == (x+1))
dubs[x]++;
}
}
p("\n\n(A) Count and display the occurences of each of the doubles");
p("\n\n Double\tOccurences\n \t-\n");
for (x=0;x<6;x++)
{
p("\n" + (x+1) +" \t\t" + dubs[x]);
}
p("\n\n\n(B) Display the most frequently occuring double or doubles = ");
histogram(dubs);
}
publicstaticvoid histogram (int [] dubs)
{
int y,x;
p("\n\n\n(C) Draw a Histogram of the occurences of each of the doubles");
p("\n\n Double\tOccurences\n \t-\n");
for(y=0;y<6;y++)
{
p("\n" + (y+1) +"\t\t");
for (x=1; x<=dubs[y];x++)
p("*");
}
p("\n\n");
}
}
Any yhelp will be greatly appreciated thank you

