Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Question 3 : A longer game of Blackjack [ 5 0 pts ] Description: Blackjack is a card game consisting of two players, the user

Question 3 : A longer game of Blackjack [50 pts]
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:
1. Both users and dealers sums of cards are smaller than or equal to 21 and users sum of cards is greater than dealers sum of cards.
2. Dealers sum of cards are greater than 21 and users sum of cards are smaller than 21.
Losing conditions are as follows:
1. Winning conditions are not satisfied.
Steps:
1. Definethesetofcardsasfollows;deck=[1234567891010101011](thereare4cardswithvalue10).
2. Each player (user and dealer) are randomly dealt two cards each from the array mentioned above. User and dealer can draw the same cards.
3. After dealing the cards, display the users cards and their sum separately in the command window. (i.e.User Card 1,User Card 2,User Sum)
4. Display ONLY the first card of the dealer in command window. (i.e Dealer Card 1)
5. 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)
6. Keep asking the question in part (e) until the user types in No.
7. 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)
8. Sum the cards of dealer but DO NOT display it to the user.
9. 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.
10. Display the total sum of the dealer in the command window. (i.e. Dealer Sum).
11. 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!)
12. 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

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

Pro SQL Server Wait Statistics

Authors: Enrico Van De Laar

1st Edition

1484211391, 9781484211397

More Books

Students also viewed these Databases questions

Question

Explain how to reward individual and team performance.

Answered: 1 week ago