Advertisement
Shavit

P. 49 Ex. 10.38

Jan 7th, 2014
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.42 KB | None | 0 0
  1. // Shavit Borisov
  2. // CW
  3.  
  4. import java.util.Random;
  5.  
  6. public class CubeScouts {
  7.  
  8.     public static void main(String[] args)
  9.    
  10.     {
  11.         final int CUBE_SIZE = 6;
  12.        
  13.         Random r = new Random();
  14.        
  15.         int[] cube = new int[CUBE_SIZE];
  16.         int current = 1;
  17.        
  18.         while(cube[current - 1] <= 2)
  19.         {
  20.             current = 1 + (r.nextInt(6));
  21.             cube[current - 1]++;
  22.         }
  23.        
  24.         System.out.printf("The winning number is %d.", current);
  25.     }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement