-2
// blackjack(7,17) -> 17  
// blackjack(21, 16) -> 21  
// blackjack(19,23) -> 19  

public int blackjack(int a, int b) {

}

After this I am really unsure of how to go about writing this code.

puzzlepalace
  • 660
  • 5
  • 13
  • 1
    Please make an effort to solve this yourself. If you fail, post the code you've tried and perhaps we can help you. – Fred Larson Apr 25 '16 at 18:34
  • ... I don't even know where to begin, that's why I don't have anything to show for it. – Savannah Apr 25 '16 at 18:42
  • 1
    what happens if a)they are the same (e.g., `blackjack(16, 16);`) or are both over 21 (e.g., `blackjack(23, 22);`). In addition to not demonstrating effort, the problem is underspecified. – KevinO Apr 25 '16 at 18:47

2 Answers2

0

Maybe something like this ?

private int blackjack(int a, int b)
{
    int aa = 21-a >= 0 ? 21-a : 22;
    int bb = 21-b >= 0 ? 21-b : 22;

    if ( aa > 21 && bb > 21 )
    {
        return -1;
    }

    return aa < bb ? a : b;
}
-1

Hi use this code.

if(a<=21 && b<=21){
    return Math.max(a, b);
}

This is a easy problem, try yourself next time.