Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Arrays;
- import java.util.Random;
- public class DiceRoll {
- public static void main(String[] args) {
- //you know the drill
- int [] arrayCharles = new int[100];
- int [] freqDistro = new int[12];
- //simulates 100 dice rolls (d12) and sorts each roll into a freqDistro array
- for (int count = 0; count < arrayCharles.length; count++) {
- Random omgSoRandom = new Random();
- arrayCharles[count] = omgSoRandom.nextInt(12) + 1;
- if (arrayCharles[count] == 1)
- freqDistro[0] = freqDistro[0] + 1;
- else if (arrayCharles[count] == 2)
- freqDistro[1] = freqDistro[1] + 1;
- else if (arrayCharles[count] == 3)
- freqDistro[2] = freqDistro[2] + 1;
- else if (arrayCharles[count] == 4)
- freqDistro[3] = freqDistro[3] + 1;
- else if (arrayCharles[count] == 5)
- freqDistro[4] = freqDistro[4] + 1;
- else if (arrayCharles[count] == 6)
- freqDistro[5] = freqDistro[5] + 1;
- else if (arrayCharles[count] == 7)
- freqDistro[6] = freqDistro[6] + 1;
- else if (arrayCharles[count] == 8)
- freqDistro[7] = freqDistro[7] + 1;
- else if (arrayCharles[count] == 9)
- freqDistro[8] = freqDistro[8] + 1;
- else if (arrayCharles[count] == 10)
- freqDistro[9] = freqDistro[9] + 1;
- else if (arrayCharles[count] == 11)
- freqDistro[10] = freqDistro[10] + 1;
- else freqDistro[11] = freqDistro[11] + 1;
- }
- //converts the freqDistro array into a string and prints it yaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaay
- System.out.println(Arrays.toString(freqDistro));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement