Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

All steps are expected to be written in MATLAB. And as a result, it is desired to come out as follows. it must be done

image text in transcribed

image text in transcribed

All steps are expected to be written in MATLAB. And as a result, it is desired to come out as follows.

it must be done in MATLAB

Question 2 (50 pts]: A longer game of Blackjack. 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 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 2. Dealer's sum of cards are greater than 21 and user's sum of cards are smaller than 21. Loring conditions are as follows: 1. Winning conditions are not satisfied Steps: 1. Define the set of cards as follows; deck 11 2 3 4 5 6 7 8 9 10 10 10 10 11] (there are 1 cards with value 10). 2. Ench player wer and denler) are randomly dealt two cards each from the array mentioned above. User and dealer can draw the same cards 3. After denling the cards, display the wor's cards and their sum separately in the command window. (i.6. "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. (.e. "Draw another eard? Yes/No") 6. Keep making 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. (.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 war. 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. 6.0. Dealer Sam). 11. Determine the winner of the round considering the Winning and Losing conditions in the Description setion. Display the winner in the command window. (.e. "Usetor Dealer) won this round") 12. Repeat this process for in total of 3 round. Finally, determine the winner of the game and display it in the command window along with the score (ie "Userfor Dealer) won the game by 2-11"). A sample output of the final round is given in Fig. 2 ---Round Number 3--- User Card 1 : 7 User Card 2 : 10 User Sum : 17 Dealer Card 1 : 10 Draw another card? (Yes or Yes No) User Card 3 : 10 User Sum : 27 Draw another card? (Yes or No) No Dealer Sum : 20 Dealer wins this round! Dealer Wins! Score 1-2 Figure 2: A sample final round of Blackjack

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

Securing SQL Server Protecting Your Database From Attackers

Authors: Denny Cherry

1st Edition

1597496251, 978-1597496254

More Books

Students also viewed these Databases questions

Question

Can Tax Court summary opinions be cited as precedent? Discuss.

Answered: 1 week ago