Results 1 to 5 of 5
  1. #1
    swathi2991 is offline Member
    Join Date
    Sep 2013
    Posts
    1
    Rep Power
    0

    Default Java Program to shuffle cards and display output as shown below

    Hi,
    I need help in writing this code. Could you please send me the code for this problem. It would be a great help for me.

    Problem.
    There are (standard) 52 playing cards. Write a program in Java to randomly mix the cards.
    You should use an array and initialize the cards with the array. At first, randomly pick a card from the array ranged from 0 to 51 and move the card to the end of the array (Whenever you pick a card, you need to reduce the maximum range by 1). Then, keep picking randomly another card until the card range is from 0 to 0.

    Output:

    Initialization
    ♣A (1), ◆A (2), ♥A (3), ♠A (4)
    ♣2 (5), ◆2 (6), ♥2 (7), ♠2 (8)
    ♣3 (9), ◆3 (10), ♥3 (11), ♠3 (12)
    ♣4 (13), ◆4 (14), ♥4 (15), ♠4 (16)
    ♣5 (17), ◆5 (18), ♥5 (19), ♠5 (20)
    ♣6 (21), ◆6 (22), ♥6 (23), ♠6 (24)
    ♣7 (25), ◆7 (26), ♥7 (27), ♠7 (28)
    ♣8 (29), ◆8 (30), ♥8 (31), ♠8 (32)
    ♣9 (33), ◆9 (34), ♥9 (35), ♠9 (36)
    ♣10 (37), ◆10 (38), ♥10 (39), ♠10 (40)
    ♣J (41), ◆J (42), ♥J (43), ♠J (44)
    ♣Q (45), ◆Q (46), ♥Q (47), ♠Q (48)
    ♣K (49), ◆K (50), ♥K (51), ♠K (52)

    after mixing the cards

    ♣3 (9), ♣8 (29), ♣K (49), ♠8 (32)
    ♥7 (27), ♣10 (37), ◆6 (22), ♣Q (45)
    ♣2 (5), ◆8 (30), ◆3 (10), ♥9 (35)
    ♣J (41), ♥8 (31), ♣5 (17), ◆4 (14)
    ♣9 (33), ♠A (4), ♥3 (11), ♠J (44)
    ◆10 (38), ♥5 (19), ♠2 (8), ♥10 (39)
    ♥Q (47), ♠K (52), ♥K (51), ♥6 (23)
    ◆A (2), ◆7 (26), ◆5 (18), ♠10 (40)
    ♣6 (21), ◆J (42), ♠5 (20), ◆K (50)
    ♠6 (24), ◆9 (34), ◆2 (6), ♥4 (15)
    ♠4 (16), ♥2 (7), ◆Q (46), ♥J (43)
    ♣7 (25), ♠3 (12), ♠Q (48), ♥A (3)
    ♣A (1), ♠7 (28), ♣4 (13), ♠9 (36)

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is online now Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,864
    Rep Power
    8

    Default Re: Java Program to shuffle cards and display output as shown below

    That is absolutely not how this works. We aren't going to do your homework for you.

    Please see the link in my signature on asking questions the smart way, then try again.
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    3,654
    Rep Power
    5

    Default Re: Java Program to shuffle cards and display output as shown below

    Indeed. Ask for help, not code.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  4. #4
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,336
    Blog Entries
    7
    Rep Power
    20

    Default Re: Java Program to shuffle cards and display output as shown below

    I don't see anything advanced in the thread, so I moved it.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  5. #5
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    United States
    Posts
    3,376
    Rep Power
    5

    Default Re: Java Program to shuffle cards and display output as shown below

    I remember this topic being covered in this forum within the last three months. Specific algorithms were even discussed. Did you first search the forum before asking the question?

    Regards,
    Jim
    The Java™ Tutorial | SSCCE | Java Naming Conventions
    Poor planning our your part does not constitute an emergency on my part.

Similar Threads

  1. Replies: 7
    Last Post: 04-11-2013, 05:31 AM
  2. Deck,shuffle, unwrap cards
    By pots in forum New To Java
    Replies: 6
    Last Post: 02-06-2013, 06:47 PM
  3. Replies: 1
    Last Post: 02-13-2012, 02:51 PM
  4. Display random cards
    By carl in forum Advanced Java
    Replies: 1
    Last Post: 08-07-2007, 07:01 AM
  5. No output shown
    By ai_2007 in forum Advanced Java
    Replies: 4
    Last Post: 07-10-2007, 09:26 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •