Question: Create a Matlab function blackjack that will take a list of numbers as input. Each number will be an integer in the range 1 to

 Create a Matlab function blackjack that will take a list of

Create a Matlab function blackjack that will take a list of numbers as input. Each number will be an integer in the range 1 to 10 and represents a playing card (1=ace, 10-Face cards such as the King, Queen, and Jack, Cards 2-10 are valued at the face value of the card) The function should calculate the best blackjack hand and display the total and the status (hit, stay, or busted) in the text variable result Use this logic: stay on 16 or higher, hit on 15 or lower, busted if greater than 21. To account for aces, calculate a total assuming a value of 1. If the total is less than 11 and there is an ace, then add 10 to the total. Try the following test cases with your function in your own version of MATLAB before submiting your code with the Submit to MATLAB button: blackjack([1 1 3]) 15 Hit! blackjack([1 9 8]) 18 - Stay! blackjack([5 7 10]) 22 - Busted! Hints: . Sum the cards tot-sum(cards); % add 'em up . Determine the number of Aces o you could use MATLAB's built-in find or any functions to determine if an ace is in the list. - e.g. if tot-16 calculation determining the total % conditional statement comparing total to 15, 16, and 21 result-sprintf( "8u - Stay!,total); elseif.... end

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!