Skip to content

Instantly share code, notes, and snippets.

@crysyn
Created October 17, 2012 22:30
Show Gist options
  • Save crysyn/3908752 to your computer and use it in GitHub Desktop.
Save crysyn/3908752 to your computer and use it in GitHub Desktop.
import java.util.Random;
import java.util.Scanner;
public class DiceProbability {
@SuppressWarnings("unused")
public static void main (String [] args)
{
Scanner in = new Scanner(System.in);
Random randNumList = new Random();
int[] times = new int[23];
int rolls = in.nextInt();
for(int i = 0; i < rolls; ++i)
times[randNumList.nextInt(12) + randNumList.nextInt(12)]++;
System.out.println("Sum of Dice Probability");
for(int i = 0; i < 23; ++i)
System.out.println((i + 2) + "s: " + times[i]);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment