Java > Logic-2 >blackJack (CodingBat Solution)

Problem:

Given 2 int values greater than 0, return whichever value is nearest to 21 without going over. Return 0 if they both go over.

blackjack(19, 21) → 21
blackjack(21, 19) → 21
blackjack(19, 22) → 19


Solution:

public int blackjack(int a, int b) {
int output=0;
if ( a > 21)
a=0;
if ( b>21)
b=0;
if ( a > b )
output = a;
else if (b>a)
output = b;

return output;
    
}


272 comments :

  1. public int blackjack(int a, int b) {
    int c=0,d=0;
    c = Math.abs(21-a);
    d = Math.abs(21-b);
    if(a>21&&b>21)
    {
    return 0;
    }
    else if(a>21)
    {
    return b;
    }
    else if(b>21)
    {
    return a;
    }
    else if(c>d)
    {
    return b;
    }
    else
    {
    return a;
    }

    }

    ReplyDelete
  2. When you bet on a blackjack game the betting takes place before any cards are dealt and the game begins. If you are playing live casino blackjack then you place your bet in a designated spot on the table.agen bola online

    ReplyDelete
  3. let's try the togel game most telling and easy to win it
    Judi Online

    ReplyDelete



  4. amazing article,thank you very much for the article and the information.. maybe if you can please visit our prediksi togel

    ReplyDelete
  5. thank you for being given the opportunity to read this very perfect article. please visit the best sports betting around the world.Sbobet

    ReplyDelete
  6. Woow, that's awesome!

    Dont forget to visit our site agen poker if u want to know more about situs poker online

    Thanks Dude!

    ReplyDelete
  7. Thanks for your information so useful for me.
    Thanks for sharing Domino QQ

    ReplyDelete
  8. playing poker it is a pleasure to waste time and relieve stress on the head go visit my website
    TaktikQQ

    ReplyDelete
  9. Thanks for your excellent posting! I quite enjoyed reading it, you happen to be a great author. I will remember to bookmark your blog and will eventually come back very soon. slot games

    ReplyDelete
  10. playing poker it is a pleasure to waste time and relieve stress on the head go visit my website
    TaktikQQ

    ReplyDelete
  11. Thanks for your excellent posting! I quite enjoyed reading it, you happen to be a great author. I will remember to bookmark your blog and will eventually come back very soon. dragon tiger

    ReplyDelete
  12. playing poker it is a pleasure to waste time and relieve stress on the head go visit my website
    TaktikQQ

    ReplyDelete
  13. Good Article very interesting Dont forget to visit my site Bandar Poker if you want to know more about

    ReplyDelete
  14. This article makes very nice and interesting thanks for your experience Visit my website if you want to know more about
    sabung ayam

    ReplyDelete
  15. playing poker it is a pleasure to waste time and relieve stress on the head go visit my website
    TaktikQQ

    ReplyDelete
  16. This information is very useful and interesting. Thank you for sharing and do not forget to visit our website to togel online if you want to know more about

    ReplyDelete
  17. This information is very useful and interesting. Thank you for sharing and do not forget to visit our website to judi online
    if you want to know more about

    ReplyDelete
  18. Woow, that's awesome!

    Dont forget to visit our site agen poker if u want to know more about situs poker online like poker online, bandarq, dominoqq or domino99

    For register click >> daftar situs poker

    Thanks Dude!

    ReplyDelete
  19. return a > 21 && b > 21 ? 0 : a > 21 ? b : b > 21 ? a : a < b ? b : a;

    ReplyDelete
  20. It is the most legitimate online club webpage in the business with awesome rewards! voodoodreams

    ReplyDelete
  21. Articles on good and interesting thanks for sharing with us, Visit my website if you want to know more about.
    togel online
    togel hkg
    togel sgp
    pengeluaran togel
    agen togel
    bandar bola
    judi bola
    agen poker
    dewa poker

    ReplyDelete
  22. this article is very interesting and also useful do not forget to visit our web site also yes

    Judi Online
    Togel Singapura
    Togel Hongkong
    Togel Online

    ReplyDelete
  23. Thank you for allow me to comment in here, YOUR ARITKEL IS VERY NICE
    poker online

    ReplyDelete

  24. This article is interesting, if you want to know more visit our website.
    live casino

    ReplyDelete
  25. This article is interesting, if you want to know more visit our website.
    live casino

    ReplyDelete
  26. This article is interesting, if you want to know more visit our website.

    roulette online

    ReplyDelete

  27. Thank you for allow me to comment in here, YOUR ARITKEL IS VERY NICE
    poker online

    ReplyDelete
  28. Thank you for allow me to comment in here

    Bandar Bola

    ReplyDelete

  29. This article is interesting, if you want to know more visit our website.

    baccarat online

    ReplyDelete
  30. This article is interesting, if you want to know more visit our website.
    dadu online

    ReplyDelete
  31. Thank you for allow me to comment in here

    Bola Online

    ReplyDelete
  32. Thank you for allow me to comment in here

    Agen Judi

    ReplyDelete
  33. This article is interesting, if you want to know more visit our website.
    dadu online indonesia

    ReplyDelete

  34. This article is interesting, if you want to know more visit our website.

    baccarat online

    ReplyDelete
  35. This article is interesting, if you want to know more visit our website.

    casino online

    ReplyDelete
  36. Playing poker it is a pleasure to waste time and relieve stress on the head go visit my website
    Domino99
    Domino qq
    Poker online

    Thank you for allow me to comment in here, YOUR ARITKEL IS VERY NICE

    ReplyDelete
  37. Articles on good and interesting thanks for sharing with us, Visit my website if you want to know more about.
    judi online
    situs judi online
    roulette
    roulette online
    baccarat
    baccarat online
    casino online
    live casino
    agen casino
    judi casino

    ReplyDelete



  38. This article is interesting, if you want to know more visit our website.

    baccarat online

    ReplyDelete


  39. Playing poker it is a pleasure to waste time and relieve stress on the head go visit my website

    Domino 99

    Thank you for allow me to comment in here, YOUR ARITKEL IS VERY NICE

    ReplyDelete
  40. Thank you for allow me to comment in here
    dadu online

    ReplyDelete
  41. Thank you for allow me to comment in here
    dadu online

    ReplyDelete


  42. Thank you for allow me to comment in here, YOUR ARTIKEL IS VERY NICE

    casino online indonesia

    ReplyDelete

  43. Thank you for allow me to comment in here, YOUR ARTIKEL IS VERY NICE

    casino online indonesia

    ReplyDelete
  44. This article is interesting, if you want to know more visit our website.
    roulette online

    ReplyDelete
  45. Thank you for allow me to comment in here

    Casino online

    ReplyDelete

  46. This article is interesting, if you want to know more visit our website.
    roulette online

    ReplyDelete



  47. Thank you for allow me to comment in here, YOUR ARTIKEL IS VERY NICE

    live casino

    ReplyDelete
  48. Thank you for allow me to comment in here
    baccarat online

    ReplyDelete
  49. this article is very interesting and also useful do not forget to visit our web site also yes

    Judi Online
    Togel Singapura

    ReplyDelete
  50. This article is interesting, if you want to know more visit our website.
    casino online

    ReplyDelete
  51. Thank you for allow me to comment in here
    dadu online

    ReplyDelete
  52. This article is interesting, hopefully useful for all of us, and don't forget to visit our website
    Judi Online
    Togel Online
    Slot Online
    Casino Online
    Judi Bola

    ReplyDelete
  53. This article is interesting, hopefully useful for all of us, and don't forget to visit our website
    Judi Online
    Togel Online
    Slot Online
    Casino Online
    Judi Bola

    ReplyDelete
  54. This article is interesting, if you want to know more visit our website.
    live casino

    ReplyDelete

  55. Thank you for allow me to comment in here
    baccarat online

    ReplyDelete
  56. Thank you for allow me to comment in here, YOUR ARITKEL IS VERY NICE

    Poker Online
    Situs Poker
    Dominoqq
    Domino99
    Bandarq
    qiu qiu

    ReplyDelete
  57. This article is interesting, if you want to know more visit our website.
    casino online

    ReplyDelete
  58. Thank you for allow me to comment in here, YOUR ARITKEL IS VERY NICE

    Poker Online
    Situs Poker
    Domino99
    Bandarq
    kiu kiu

    ReplyDelete
  59. This article is interesting, hopefully useful for all of us, and don't forget to visit our website
    Judi Online
    Togel Online
    Slot Online
    Casino Online
    Judi Bola

    ReplyDelete
  60. This article is interesting, hopefully useful for all of us, and don't forget to visit our website
    Judi Online
    Togel Online
    Slot Online
    Casino Online
    Judi Bola

    ReplyDelete
  61. This article is interesting, hopefully useful for all of us, and don't forget to visit our website
    Judi Online
    Togel Online
    Slot Online
    Casino Online
    Judi Bola

    ReplyDelete
  62. This article is interesting, hopefully useful for all of us, and don't forget to visit our website
    Judi Online
    Togel Online
    Slot Online
    Casino Online
    Judi Bola

    ReplyDelete
  63. Thank you for allow me to comment in here, YOUR ARTICLE IS VERY NICE

    Poker Online
    Situs Poker
    Domino99
    Bandarq
    kiu kiu

    ReplyDelete

  64. This article is interesting, if you want to know more visit our website.
    casino online

    ReplyDelete
  65. Thank you for allow me to comment in here, YOUR ARTICLE IS VERY NICE

    Poker Online
    Situs Poker
    Domino99
    Bandarq
    kiu kiu

    ReplyDelete
  66. This article is interesting, if you want to know more visit our website.
    casino online

    ReplyDelete
  67. This article is interesting, hopefully useful for all of us, and don't forget to visit our website
    Judi Online
    Togel Online
    Slot Online
    Casino net
    Judi Bola

    ReplyDelete
  68. Thank you for allow me to comment in here, YOUR ARTIKEL IS VERY NICE

    roulette online indonesia

    ReplyDelete
  69. Thank you for allow me to comment in here, YOUR ARTICLE IS VERY NICE

    Poker Online
    Situs Poker
    Domino99
    Bandarq
    kiu kiu

    ReplyDelete
  70. Thank you for allow me to comment in here, YOUR ARTIKEL IS VERY NICE

    live casino

    ReplyDelete
  71. This article is interesting, if you want to know more visit our website.
    live casino

    ReplyDelete
  72. This article is interesting, hopefully useful for all of us, and don't forget to visit our website
    Judi Online
    Togel Online
    Slot Online
    Casino com
    Judi Bola

    ReplyDelete
  73. This article is interesting, if you want to know more visit our website.

    dadu online

    ReplyDelete
  74. This article is interesting, hopefully useful for all of us, and don't forget to visit our website
    Judi Online
    Togel Online
    Slot Online
    Casino Online
    Judi Bola

    ReplyDelete
  75. This article is interesting, hopefully useful for all of us, and don't forget to visit our website
    Judi Online
    Togel Online
    Slot Online
    Casino com
    Judi Bola

    ReplyDelete
  76. Thanks have been given the opportunity to comment. Hopefully what you provided is useful for all those who need them. Visit my website if you want to know more about www.12naga.com


    judi online terpercaya
    taruhan bola
    Poker Online
    togel online
    casino online
    sabung ayam online
    tangkas online terpercaya
    slot online
    agen bola online

    ReplyDelete
  77. Thank you for allow me to comment in here, YOUR ARTIKEL IS VERY NICE

    roulette online indonesia

    ReplyDelete
  78. This article is interesting, if you want to know more visit our website.
    live casino


    ReplyDelete
  79. This article is interesting, if you want to know more visit our website.

    dadu online

    ReplyDelete
  80. Thank you for allow me to comment in here, YOUR ARTIKEL IS VERY NICE, if you want to know more visit our website.
    live casino
    WA : +6285770811989

    ReplyDelete
  81. Thank you for allow me to comment in here, YOUR ARTIKEL IS VERY NICE, if you want to know more visit our website.
    live casino
    WA : +6285770811989

    ReplyDelete
  82. This article is interesting, if you want to know more visit our website.

    dadu online
    WA : +62 813 5504 1626

    ReplyDelete
  83. Thank you for allow me to comment in here, YOUR ARTIKEL IS VERY NICE, if you want to know more visit our website.
    live casino
    WA : +6285770811989

    ReplyDelete
  84. This article is interesting, if you want to know more visit our website.

    dadu online
    WA : +62 813 5504 1626


    ReplyDelete
  85. This article is interesting, if you want to know more visit our website.
    live casino
    WA : +62 813 5504 1626

    ReplyDelete
  86. Hi there, I found your blog via Google while looking for a related topic, your site came up, it looks great. I’ve bookmarked it in my google bookmarks. 먹튀검증 

    ReplyDelete
  87. Thank you for allow me to comment in here, YOUR ARTIKEL IS VERY NICE

    live casino
    WA : +62 813 9661 0283

    ReplyDelete
  88. Your blogger is great, and makes everyone see your blog over and over again

    Jasabola
    Liga88
    Dewa poker 88

    ReplyDelete
  89. Your blogger is great, and makes everyone see your blog over and over again

    Slot Online Terpercaya
    Jasabola
    Liga88

    ReplyDelete
  90. The web site is lovingly serviced and saved as much as date. So it should be, thanks for sharing this with us. 트레이딩벳 먹튀

    ReplyDelete
  91. Intriguing post. I Have Been pondering about this issue, so much obliged for posting. Really cool post.It "s truly extremely pleasant and Useful post.Thanks sbobet

    ReplyDelete
  92. It's truly a nice and useful piece of information. I'm satisfied
    that you just shared this useful information with us.
    Please stay us up to date like this. Thank you for
    sharing.
    ميز تحرير
    خريد ميز تحرير
    ميز تحرير ديواري
    ميز تحرير جديد
    قيمت ميز تحرير
    ميز مطالعه
    ميز تحرير دخترانه

    ReplyDelete
  93. Just admiring your work and wondering how you managed this blog so well. It’s so remarkable that I can't afford to not go through this valuable information whenever I surf the internet!  https://www.casinochan.com/

    ReplyDelete
  94. Incredible articles and awesome design. Your blog entry merits the greater part of the positive input it"s been getting. บาคาร่า

    ReplyDelete

  95. This article is interesting, if you want to know more visit our website.
    Togel Singapura

    ReplyDelete


  96. This article is interesting, if you want to know more visit our website.
    Togel Singapura
    Slot Game
    live casino online

    ReplyDelete
  97. thank you for being given a chance to comment on this great article. do not forget to visit us

    Agen Bola Online

    Casino Online

    Judi Online

    Agen Togel

    Bandar Bola

    ReplyDelete
  98. thank you for being given a chance to comment on this great article. do not forget to visit us

    Agen Bola Online

    Casino Online

    Judi Online

    Agen Togel

    Bandar Bola

    ReplyDelete
  99. This article is interesting, hopefully useful for all of us, and don't forget to visit our website
    Judi Online
    Togel Online
    Slot Online
    Casino Online
    Judi Bola

    ReplyDelete
  100. thank you for being given a chance to comment on this great article. do not forget to visit us

    Agen Bola Online

    Casino Online

    Judi Online

    Agen Togel

    Bandar Bola

    ReplyDelete




  101. This article is interesting, if you want to know more visit our website.
    Togel Singapura
    Slot Game
    live casino online

    ReplyDelete
  102. thank you for being given a chance to comment on this great article. do not forget to visit us

    Agen Bola Online

    Casino Online

    Judi Online

    Agen Togel

    Bandar Bola

    ReplyDelete






  103. This article is interesting, if you want to know more visit our website.
    Togel Singapura
    Slot Game
    live casino online

    ReplyDelete
  104. thank you for being given a chance to comment on this great article. do not forget to visit us

    Agen Bola Online

    Casino Online

    Judi Online

    Agen Togel

    Bandar Bola

    ReplyDelete




  105. This article is interesting, if you want to know more visit our website.
    situs judi online


    ReplyDelete
  106. This article is interesting, hopefully useful for all of us, and don't forget to visit our website
    Judi Online
    Togel Online
    Slot Online
    Casino Online
    Judi Bola

    ReplyDelete


  107. This article is interesting, if you want to know more visit our website.
    situs judi online

    ReplyDelete
  108. Thank you for allow me to comment in here, YOUR ARITKEL IS VERY NICE

    Situs Judi
    Situs Judi Online
    Casino Online

    ReplyDelete
  109. thank you for being given a chance to comment on this great article. do not forget to visit us

    Agen Bola Online

    Casino Online

    Judi Online

    Agen Togel

    Bandar Bola

    ReplyDelete
  110. Why can you make this good article? I hope you can also give input to me for this brilliant idea at Agen Casino Online Terpercaya I'm waiting bro.
    Perisakti Prediksi Togel dan Bola Paling Jitu

    ReplyDelete
  111. Very interesting article so I want to follow the tips and tricks you give. Don't forget to visit the site that I created too Agen Togel Online I am waiting for your arrival on my site.
    Prediksi Togel Paling Jitu dan Terupdate

    ReplyDelete
  112. I was very amazed by the article you made, very useful and meaningful. I hope you also visit my site at Agen Casino Slot Online Terpercaya okay bro.
    Prediksi Paling Lengkap dan Jitu

    ReplyDelete
  113. You are very talented in making quality articles. Please give me guidance for the article I made, I hope you visit it Agen Togel Online Terpercaya thank you.

    ReplyDelete
  114. Excellent .. Amazing .. I’ll bookmark your blog and take the feeds also…I’m happy to find so many useful info here in the post, we need work out more techniques in this regard, thanks for sharing pls visit me at : http:/agentogel.co.id

    ReplyDelete

Follow Me

If you like our content, feel free to follow me to stay updated.

Subscribe

Enter your email address:

We hate spam as much as you do.

Upload Material

Got an exam, project, tutorial video, exercise, solutions, unsolved problem, question, solution manual? We are open to any coding material. Why not upload?

Upload

Copyright © 2012 - 2014 Java Problems  --  About  --  Attribution  --  Privacy Policy  --  Terms of Use  --  Contact