Answered step by step
Verified Expert Solution
Question
1 Approved Answer
MatLAB In the game of Blackjack a player can draw cards from a deck until the sum of their card values reaches 21. Create a
MatLAB
In the game of Blackjack a player can draw cards from a deck until the sum of their card values reaches 21. Create a while loop. In each iteration generate a random number between 1 and 11. Show the drawn cards (random numbers). Add all these random numbers together until their sum becomes greater than or equal to 21. Then print out the sum and the number of cards dealt.
Hint: Use the rand function. Example, floor(rand()*11 + 1 )
Example of output: Random cards:
1-4
2-3
3-9
4-3
5-6
Hand Score is 25, Number of Cards is 5
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