elseif playerscore 21 player hits blackjack output I got a Blackjack else

Elseif playerscore 21 player hits blackjack output i

This preview shows page 1 - 2 out of 2 pages.

elseif player_score == 21 % player hits blackjack output = 'I got a Blackjack!'; else output = sprintf('I got a score of %d.',player_score); % store players score in output vector end if dealer_score > 21 % dealer score is greater than 21 output = strcat(output,' The Dealer busted.'); % concatenate 2nd sentence to output vector elseif dealer_score == 21 % dealer hits blackjack output = strcat(output,' The Dealer got a Blackjack!'); % concatenate 2nd sentence to output vector else output = strcat(output,sprintf(' The Dealer got a score of %d.',dealer_score)); % concatenate 2nd sentence to output vector end % condition for player win if player score is less than 21 and less % than dealer score also if dealer got busted and player did not if (player_score > dealer_score && player_score <= 21) || (player_score <= 21 && dealer_score > 21) output = strcat(output,' I win!'); elseif player_score <= dealer_score && dealer_score <= 21 % dealer wins if player score less than equal to dealer score and dealer not busted output = strcat(output,' The Dealer wins!'); elseif player_score > 21 && dealer_score > 21 % if both busted output = strcat(output,' We both busted.'); end
Image of page 1
output = cellstr(output); % convert output vector to cell array of characters end
Image of page 2

You've reached the end of your free preview.

Want to read both pages?

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern

Stuck? We have tutors online 24/7 who can help you get unstuck.
A+ icon
Ask Expert Tutors You can ask You can ask You can ask (will expire )
Answers in as fast as 15 minutes