The task is to create a program that will randomly select four cards from a deck of 52 cards. All the cards can be represented using an array named deck, filled with initial values 0 to 51, as follows:Card numbers 0–12, 13–25, 26–38, and 39–51 represent 13 Spades, 13 Hearts, 13 Diamonds, and 13 Clubs, respectively, as shown in Figure 1. cardNumber / 13 determines the suit of the card, and cardNumber % 13 determines the rank of the card, as shown in Figure 2. After shuffling the array deck, pick the first four cards from deck. The program displays the cards from these four card numbers. Implement the following code in Eclipse, and ensure it runs without errors. Think about the following questions and write down your answers in a few sentences. 1) Describe how the above program shuffles the cards. 2) Describe how deck[i] / 13 and deck[i] % 13 work to display the suit and rank of cards.
The task is to create a
All the cards can be represented using an array named deck, filled with initial values 0 to 51, as
follows:Card numbers 0–12, 13–25, 26–38, and 39–51 represent 13 Spades, 13 Hearts, 13 Diamonds, and
13 Clubs, respectively, as shown in Figure 1. cardNumber / 13 determines the suit of the card,
and cardNumber % 13 determines the rank of the card, as shown in Figure 2. After shuffling the
array deck, pick the first four cards from deck. The program displays the cards from these four
card numbers.
Implement the following code in Eclipse, and ensure it runs without errors.
Think about the following questions and write down your answers in a few sentences.
1) Describe how the above program shuffles the cards.
2) Describe how deck[i] / 13 and deck[i] % 13 work to display the suit and rank of cards.
Trending now
This is a popular solution!
Step by step
Solved in 5 steps with 2 images