Question
1. Write a C++ program that plays the casino game blackjack, or 21. Blackjack is a competition between the dealer and player(s) to see who
1. Write a C++ program that plays the casino game blackjack, or 21. Blackjack is a competition between the dealer and player(s) to see who can get closest to 21 points without going over (busting). Implementation Notes The player is dealt two cards face up, and the dealer (computer) initially only show one of his cards face up. The player has the choice to take a card (hit) or to stay with what he has. A hands present total is calculated by simply adding the face value of the cards. In blackjack, the cards are valued as follows: o AnAcecancountaseither1or11(theAcevalueonlybecomes1iftheplayerwould otherwise have bust). o Thecardsfrom2through10arevaluedasindicated. o TheJ,Q,andKareallvaluedat10. The suits of the cards do not have any meaning in the game. The player may keep taking cards until he chooses to stay, or until his cards total more than 21. If this happens the player is deemed to have bust and losses the hand. The hand is then over. If the player has stayed on 21 or less it is the dealers turn to take cards. The dealer must follow very fixed rules and keep taking cards until he has at least 17, and he must stop when he gets 17 or more. If through taking cards the dealers total exceeds 21 he too busts. If the dealer busts and the player remains, then the player wins the hand. If the dealer does not bust the winner of the hand is the person with the highest total, whether that be the dealer or the player. If the totals are identical a push results and the hand is deemed a draw (tie). The best hand in the game is called blackjack- this consists of an Ace and any card valued at 10, in any order. If the dealer gets blackjack he automatically wins the hand unless the player also has a blackjack in which case a push (draw) results. A standard deck of cards is used- no jokers. Use 3 card decks- and reshuffle decks when less than 10 cards are available. Use card character symbols: o -clubs -spades -hearts -diamonds Modifications to above: Have the dealer (computer) initially only show one of his cards face up. Example: Dealers cards: [?] XX Q Here the value of the hand is unknown. Once the player has finished his turn he will reveal his other card. Then ask user to play again. COSC 1437 S18 1 Dealers cards: [?] XX Q Your cards: [11] 6 5 (S)-Stand or (H)-Hit or (Q)-Quit? H You drew: [17] 6 (S)-Stand or (H)-Hit or (Q)-Quit? S Dealers cards: [20] Q Q Dealer wins Game over. Good-bye. The prompt for intra-round commands must show which commands are currently available for the player. Not all commands are always available. (H)-Hit (S)-Stand (D)-Double Down (P)-Split (I)-Insurance (Q)-Quit Create a menu that allows the user to: Input values from keyboard (like above)- demo mode Input values from a randomly generated values (default)- game mode Do you wish to play in (E)-Demo or (G)-Game mode? e Use a string to enter the players name via the keyboard. Enter player name: James Implement simple betting- Rules: Only the player can bet Bets must be made before any cards are dealt. The minimum bet must be $5 and the maximum bet of $100. Initial value of $100 - if the player loses, subtract the bet from the money, else if wins, add amount equal to the users money. The game should quit when the player runs out of money. The player can only bet in $5 increments. If the player gets a blackjack he/she gets two and one half his bet (3-2 odds) as opposed to the normal return for winning. James you have $100 dollars. How much do you want to bet? 100 Dealers cards: [?] XX 7 Your cards: [16] A 5 (S)-Stand or (H)-Hit or (Q)-Quit? H Your cards: [17] A 5 A (S)-Stand or (H)-Hit or (Q)-Quit? h COSC 1437 S18 2 Your cards: [15] A 5 A 8 (S)-Stand or (H)-Hit or (Q)-Quit? S Dealers cards: [10] 3 7 Dealer drew: [12] 2 Dealer drew: [15] 3 Dealer drew: [19] 4 Dealer wins James loses $100 Game over. Good-bye. Other features to add: Insurance- When the dealers face up card is an ace, a side bet of up to half of the original bet that the dealers face down card is a ten (point) card, thus a blackjack for the house. If the dealers card is a ten card, it is turned up, and the player who made the insurance bet wins and paid double the amount of their half bet- 2 to 1 payoff. If the player has blackjack as well- it is a stand-off (tie). Doubling Down. Another option open to the player is doubling his bet when the original two cards dealt total 9, 10, or 11. When the player's turn comes, he places a bet equal to the original bet, and the dealer gives him just one card, which is placed face down and is not turned up until the bets are settled at the end of the hand. With two fives, the player may split a pair, double down, or just play the hand in the regular way. Splitting Pairs. If a player's first two cards are of the same denomination, such as two jacks or two sixes, he may choose to treat them as two separate hands when his turn comes around. The amount of his original bet then goes on one of the cards, and an equal amount must be placed as a bet on the other card. The player first plays the hand to his left by standing or hitting one or more times; only then is the hand to the right played. The two hands are thus treated separately, and the dealer settles with each on its own merits. Doubling down is allowed after a split. With a pair of aces, the player is given one card for each ace and may not draw again. Also, if a ten-card is dealt to one of these aces, the payoff is equal to the bet (not one and one-half to one, as with a blackjack at any other time)- this is not a blackjack but a regular 21. The dealer may never double-down, split, or take insurance. Use user-defined functions in your program. Output should by user friendly. Name the project: BlackjackXX.cpp, where XX are your initials.
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