Advertisement
Shavit

P. 142 Ex. 5.55

Oct 20th, 2013
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.57 KB | None | 0 0
  1. // Shavit Borisov
  2. // CW
  3.  
  4. import java.util.Random;
  5.  
  6. public class RandomCards {
  7.  
  8.     public static void main(String[] args)
  9.    
  10.     {
  11.         Random r = new Random ();
  12.        
  13.         int num = 1+r.nextInt(13);
  14.         int shape = 1 + r.nextInt(4);
  15.        
  16.         switch (shape)
  17.         {
  18.             case 1:
  19.                 System.out.printf("Your card is %d Heart.", num);
  20.                 break;
  21.             case 2:
  22.                 System.out.printf("Your card is %d Club.", num);
  23.                 break;
  24.             case 3:
  25.                 System.out.printf("Your card is %d Diam.", num);
  26.                 break;
  27.             case 4:
  28.                 System.out.printf("Your card is %d Spade.", num);
  29.                 break;
  30.         }
  31.        
  32.     }
  33.  
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement