use Ace as 11
Objectives To practice using if statements. The Assignment For this assignment, you will write a program that tells the user to hit or 'stand in a game of Blackjack (also known as Tiventy-one) Blackjack is a casino card game where the objective is to have the cards you are dealt total up as close to 21 as possible. If you go over 21 (a bust), you lose. The cards are from a standard deck (most casinos use several decks at once) Cards 2-10 have the values shown. Face cards (Jack, Queen and King) have value 10. A Ace is either 1 or 11, whichever is to your advantage. Each player is initially dealt two cards face up. The dealer is given 1 card face up and 1 card face down. Then, each player gets one turn to ask for as many extra cards as he wants, one at a time. To receive another card, the player "hits". When he doesn't want any more cards, he "stands If you don't know Blackjack, you can find the rules for Blackjack on Wikipedia, but it is simplest to wait for the demo in class The strategy that you will implement is a rather simple one. You will probably lose money slowly in a casino if you follow this strategy (If you don't follow a strategy like this one, you will lose money quickly) If your cards total 17 or higher, always stand regardless of what the dealer is showing in his face-up card If your cards total 11 or lower, always hit. If your cards add up to 13 to 16 (inclusive), hit if the dealer is showing 7 or higher, otherwise stand . If your cards add up to 12, hit unless the dealer is showing 4 to 6 (inclusive). In that case, stand The sample runs of your program should look like this: PT[122)% gcc -Wall blackjack-c r(123)% ./a . out Here's sone advice for blackjack. Tell me which card the dealer is showing Enter 2-9, 10 (Jack, Queen, King) or 11 (Ace): What is the combined total of your hand? You should: Hit Notes Please name your program blackjack.c You will obviously use lots of if statements For ease of debugging, make sure that you indent your program properly. Always, use curly braces, ( and ), even when the body of the if or else part only has a single statement Use && for logical AND and |1 for logical OR . You may have to use if statements inside another if statement Blackjack is one of very few games where the player has a statistical chance of actually beating the casino using a strategy called "card counting" where the player tries to remember the distribution of cards that have been played (For example the player might try to remember the number of Aces that have played.) Casinos routinely kick out card counters. counting strategy . been Here's arecent Newsweck article on Edward Thorp, the math professor who developed the first card