Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Shavit Borisov
- // CW
- import java.util.Scanner;
- import java.util.Random;
- public class RandomCube {
- public static void main(String[] args)
- {
- final int CUBE_SIZE = 6;
- Scanner in = new Scanner(System.in);
- Random r = new Random();
- int[] cube = new int[CUBE_SIZE];
- int length;
- int current;
- System.out.printf("Enter the nubmer of times you would like to throw the cube: ");
- length = in.nextInt();
- for(int i = 0; i < length; i++)
- {
- current = 1 + (r.nextInt(6));
- cube[current - 1]++;
- }
- for(int i = 0; i < CUBE_SIZE; i++)
- System.out.printf("The number of times ~%d~ was generated is %d.\n", i + 1, cube[i]);
- in.close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement