Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Modifications: 1. As it is, the code only displays the first four cards of the deck. Modify it so that the user is asked how
Modifications: 1. As it is, the code only displays the first four cards of the deck. Modify it so that the user is asked how many cards they want and the sum value of those cards. Also indicate to the user if the sum of the cards is over 21, at 21, or under 21. Aces are worth 1 point. Cards with numbers are worth that amount. Jacks, Queens, Kings are worth 10 points. 2. The output would look like this: . "The deck is shuffled. How many cards do you want?" 5 The player wants 5 cards: Card number 6: 7 of Spaces Card number 48: 10 of Clubs Card number 11: Queen of Spades Card number 24: Queen of Hearts Card number 2: 4 of Clubs The numerical value of those cards together is 41 which is over 21 Hint: To find the numerical value of a card, print out what deck[i] % 13 displays in the loop. Add this value to your total. Make sure you handle face cards properly. For example, the Queen might be 12 points, but you don't want to add 12 to the total. LISTING 7.2 DeckOfCards.java 1 public class DeckOfCards { public static void main(String[] args) { int[] deck = new int[52]; String[] suits = {"Spades", "Hearts", "Diamonds", "Clubs"}; String[] ranks = {"Ace", "2", "3", "4", "5", "6","7", "8", "9", "10", "Jack", "Queen", "King"}; // Initialize the cards for (int i = 0; i
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started