Advertisement
Guest User

Untitled

a guest
Jun 27th, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2.  
  3. public class Probability {
  4.     public static void main(String[] args) {
  5.         CardDeck deck;
  6.         int success = 0;
  7.         int x = 1;
  8.         int fail;
  9.         for (int i = 0; i < 1000; i++) {
  10.             fail = 0;
  11.             deck = new CardDeck();
  12.             deck.shuffle();
  13.             while (deck.moreCards()) {
  14.                 for (x = 1; deck.moreCards(); x++) {
  15.                     if (deck.getCard().getRank() == x) {
  16.                         fail = 1;
  17.  
  18.                         break;
  19.                     }
  20.                     if (x == 3) {
  21.                         x = 0;
  22.                     }
  23.                 }
  24.                 if (fail == 0) {
  25.                     success++;
  26.                 }
  27.             }
  28.         }
  29.         System.out.println((double) success / 1000);
  30.     }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement