Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Description: Blackjack is a card game consisting of two players, the user ( you ) and the dealer ( the computer ) . Each player

Description: Blackjack is a card game consisting of two players, the user (you) and the dealer (the computer). Each
player is randomly dealt two cards which can be valued from 1 to 11. Both user and dealer can draw additional cards.
Winning conditions are as follows:
Both user's and dealer's sums of cards are smaller than or equal to 21 and user's sum of cards is greater than
dealer's sum of cards.
Dealer's sum of cards are greater than 21 and user's sum of cards are smaller than 21.
Losing conditions are as follows:
Winning conditions are not satisfied.
Steps:
Each player (user and dealer) are randomly dealt two cards each from the array mentioned above. User and
dealer can draw the same cards.
After dealing the cards, display the user's cards and their sum separately in the command window. (i.e. "User
Card 1", "User Card 2", "User Sum")
Display ONLY the first card of the dealer in command window. (i.e "Dealer Card 1")
Add the option to draw another random card from the deck for the user by asking for an input in the command
window. (i.e. "Draw another card? Yes/No")
Keep asking the question in part (e) until the user types in "No".
Add the drawn card(s) to the previous sum. Display the drawn card(s) and the new sum in the command
window. (i.e. "User Card 3", "User Card 4"... "User Card N", "New User Sum")
Sum the cards of dealer but DO NOT display it to the user.
Draw a single card for the dealer with 50% probability if the sum of initially dealt cards are less than 17. If
another card is dealt to the dealer, add it to the previous sum.
Display the total sum of the dealer in the command window. (i.e. Dealer Sum).
Determine the winner of the round considering the Winning and Losing conditions in the Description section.
Display the winner in the command window. (i.e. "User(or Dealer) won this round!")
Repeat this process for in total of 3 rounds. Finally, determine the winner of the game and display it in the
command window along with the score. (i.e "User(or Dealer) won the game by 2-1!"). A sample output of the
final round is given in Fig. 2
image text in transcribed

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

Step: 3

blur-text-image

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

Big Data Fundamentals Concepts, Drivers & Techniques

Authors: Thomas Erl, Wajid Khattak, Paul Buhler

1st Edition

0134291204, 9780134291208

More Books

Students also viewed these Databases questions

Question

What is a (a) dichotomous variable? (b) binary variable?

Answered: 1 week ago