id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

fund_blackjack


Imagine you are playing the card game Blackjack where you get dealt two playing cards. In the game Blackjack, the player tries to get as close to a hand total of 21 as possible without going over. It most often is beneficial to hit (get another card) if you have a hand value of 16 or less and to stay (end your turn) if you have a hand value of 17 or more.

Given two integers indicating the values of the two cards in your hand, return the String "hit" or "stay" based on the optimal plan written above!


fund_blackjack(5, 7) → "hit"
fund_blackjack(1, 2) → "hit"
fund_blackjack(8, 10) → "stay"

...Save, Compile, Run (ctrl-enter)

public String fund_blackjack(int a, int b) { }

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Java Help

Misc Code Practice

Post-solution available

Copyright Nick Parlante 2017 - privacy