//Here is a simple code to simulate the rolling of one die..
//We will try to adapt it to the rolling of 2 die.
public class Dice {
private static void doRawRandomNumber() {
int[] Myarray;
Myarray=new int[13];
for (int k=0; k<13; k++){
Myarray[k] =0;
}
for (int i=1; i<1000001; i++){
double rawRandomNumber;
rawRandomNumber = Math.random();
int dice1 = (int)(rawRandomNumber*6)+1;
//System.out.println("-------------------------------------------------");
//System.out.println(" roll # "+i);
//System.out.println("Die #1 : " + dice1);
// System.out.println("-------------------------------------------------");
// System.out.println("\n");
rawRandomNumber = Math.random();
int dice2 = (int)(rawRandomNumber*6)+1;
//System.out.println("-------------------------------------------------");
// System.out.println("Die #2 : " + dice2);
//System.out.println("-------------------------------------------------");
//System.out.println("\n");
int answer;
answer = dice1 + dice2;
//System.out.println("-------------------------------------------------");
//System.out.println("Answer: " + answer);
Myarray[answer]=Myarray[answer]+1;
//System.out.println("-------------------------------------------------");
//System.out.println("\n");
}
for (int k=0; k<13; k++){
System.out.println(k +" occurred " + Myarray[k]+ " times");
}
}
/**
* Sole entry point to the class and application.
* @param args Array of String arguments.
*/
public static void main(String[] args) {
doRawRandomNumber();
}
}