Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

write a program to play the game of Blackjack in C.Blackjack is a comparing card game where each player competes against the dealer to be

write a program to play the game of Blackjack in C.Blackjack is a comparing card game where each player competes against the dealer to be the first to reach 21. In your case, the computer is the dealer and the user of your program is the other player. there are a few modifications in the game.

The first change is regarding the objective of the game. In our version, the objective of the game is to beat the dealer in one of the following ways: Get 21 points on the player's first two cards (called a "blackjack"), without a dealer blackjack; or Reach a final score higher than the dealer without exceeding 21. If the dealer and the player get the same points and it is not a blackjack for the player, then the games is determined to be a draw.

The second change is regarding the drawing of cards: the dealer at most, draws two cards for itself; the player can draw cards as long as the sum of player's cards at that instance have not yet exceeded 21.

Finally, in this assignment's Blackjack the player can only make the following decisions: Hit (H): take another card from the dealer. Stay (S): take no more cards from the dealer. A card in your game can have any of the following values: A, 2, 3, 4, 5, 6, 7, 8, 9, J, Q, K Card values:

The cards between 2 to 9 have the same value as the numbers on them J, Q, K each count as 10. A can count as 1 or 11. You program should at least have the following function(s): char draw_card() Returns one of the following characters at random {'A', '2', '3', '4', '5', '6', '7', '8', '9', 'J', 'Q', 'K'}. It does not take any input parameters. If you want you can have additional functions of your own.

Example Interaction

Example 1:

Dealer card: 8

Player card: K

Dealer card: hidden

Player card: 9

Hit or Stay (H/S)? S

The hidden dealer card was: 3

Dealer sum = 12

Player sum = 19

You Won!

Example 2:

Dealer card: 5

Player card: 2

Dealer card: hidden

Player card: 9

Hit or Stay (H/S)? H

Player card: 7

Hit or Stay (H/S)? H

Player card: 5

The hidden dealer card was: A

Dealer sum = 16

Player sum = 23

You Lost!

Example 3:

Dealer card: 2

Player card: K

Dealer card: hidden

Player card: A

BLACKJACK!!!

The hidden dealer card was: Q

Dealer sum = 12

Player sum = 21

You Won!

THANKYOU!

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Database Management

Authors: Jeff Hoffer, Ramesh Venkataraman, Heikki Topi

13th Edition Global Edition

1292263350, 978-1292263359

Students also viewed these Databases questions

Question

Give details of the use of ICT in workforce planning

Answered: 1 week ago

Question

Explain the various meanings of and approaches to flexible working

Answered: 1 week ago