Advertisement
Adumb_Copper

Dice Roller

Nov 23rd, 2014
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.95 KB | None | 0 0
  1. import java.util.Arrays;
  2. import java.util.Random;
  3.  
  4.  
  5. public class DiceRoll {
  6.  
  7.     public static void main(String[] args) {
  8.        
  9.         //you know the drill
  10.         int [] arrayCharles = new int[100];
  11.         int [] freqDistro = new int[12];
  12.        
  13.         //simulates 100 dice rolls (d12) and sorts each roll into a freqDistro array
  14.         for (int count = 0; count < arrayCharles.length; count++) {
  15.                
  16.                 Random omgSoRandom = new Random();
  17.                
  18.                 arrayCharles[count] = omgSoRandom.nextInt(12) + 1;
  19.                
  20.                 if (arrayCharles[count] == 1)
  21.                     freqDistro[0] = freqDistro[0] + 1;
  22.                 else if (arrayCharles[count] == 2)
  23.                     freqDistro[1] = freqDistro[1] + 1;
  24.                 else if (arrayCharles[count] == 3)
  25.                     freqDistro[2] = freqDistro[2] + 1;
  26.                 else if (arrayCharles[count] == 4)
  27.                     freqDistro[3] = freqDistro[3] + 1;
  28.                 else if (arrayCharles[count] == 5)
  29.                     freqDistro[4] = freqDistro[4] + 1;
  30.                 else if (arrayCharles[count] == 6)
  31.                     freqDistro[5] = freqDistro[5] + 1;
  32.                 else if (arrayCharles[count] == 7)
  33.                     freqDistro[6] = freqDistro[6] + 1;
  34.                 else if (arrayCharles[count] == 8)
  35.                     freqDistro[7] = freqDistro[7] + 1;
  36.                 else if (arrayCharles[count] == 9)
  37.                     freqDistro[8] = freqDistro[8] + 1;
  38.                 else if (arrayCharles[count] == 10)
  39.                     freqDistro[9] = freqDistro[9] + 1;
  40.                 else if (arrayCharles[count] == 11)
  41.                     freqDistro[10] = freqDistro[10] + 1;
  42.                 else freqDistro[11] = freqDistro[11] + 1;
  43.                
  44.        
  45.         }
  46.    
  47.     //converts the freqDistro array into a string and prints it yaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaay
  48.         System.out.println(Arrays.toString(freqDistro));
  49.    
  50.     }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement