Question: Game of 21: Write a program that simulates a game of 21 from the dealer's perspective. You do not have to add a player. Just
Game of 21: Write a program that simulates a game of 21 from the dealer's perspective. You do not have to add a player. Just focus on the dealer.
Have the dealer (computer) take two cards. Don't worry if the dealer gets the same card more than once; most dealers actually have a "shoe" that holds all their cards and they have multiple decks in the shoe at any time.
If the value of the cards adds up to 10 or less, draw another card.
Keep the dealer drawing cards until his total is 17 or higher.
Once the dealer gets to 17 or higher....
If the dealer goes over 21, he has busted.
If the dealer gets exactly 21, he has won.
If the dealer gets less than 21, he has lost.
You may reuse your card / card translator for this.
An Ace is worth 1 "point" if the other cards in the hand total more than 10. But an Ace is worth 10 points if the other cards in the hand when it is dealt total up to 10 or less.
Example Output:
Dealer first 2 cards: Ace of Diamonds and Two of Hearts
Dealer has 12
Dealer next card: Three of Clubs
Dealer has 15
Dealer next card: Ace of Hearts
Dealer has 16
Dealer next card: Five of Clubs
Dealer has 21. Dealer won.
USE JAVA
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
