Advertisement
Guest User

Untitled

a guest
May 14th, 2014
368
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.70 KB | None | 0 0
  1. import java.util.Random;
  2. import java.util.Scanner;
  3.  
  4.  
  5. public class RandomHandsOf5Cards {
  6.  
  7.     public static void main(String[] args) {
  8.         Scanner scn = new Scanner(System.in);
  9.         int numberOfHands = scn.nextInt();
  10.         String[] cards = {"2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K","A"};
  11.         String[] faces = {"♣", "♦", "♥", "♠" };
  12.         Random rnd = new Random();
  13.         for(int i = 0;i<numberOfHands;i++){
  14.                 System.out.printf("%s%s %s%s %s%s %s%s %s%s%n",cards[rnd.nextInt(13)],faces[rnd.nextInt(4)],cards[rnd.nextInt(13)],faces[rnd.nextInt(4)],cards[rnd.nextInt(13)],faces[rnd.nextInt(4)],cards[rnd.nextInt(13)],faces[rnd.nextInt(4)],cards[rnd.nextInt(13)],faces[rnd.nextInt(4)]);
  15.         }
  16.     }
  17.  
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement