Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Use matlab pls. Challenge problem! This problem uses many of the concepts from module 1. The hints below should help you build your programs. This
Use matlab pls.
Challenge problem! This problem uses many of the concepts from module 1. The hints below should help you build your programs. This practice problem is longer and more difficult than a typical quiz problem. 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([113]) 15 - Hit! blackjack([1 981) 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 % conditional statement comparing total to 15, 16, and 21 result=sprintf('%u - Stay!', total): elseif endStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access with AI-Powered 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