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;
    
}


83 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. return a > 21 && b > 21 ? 0 : a > 21 ? b : b > 21 ? a : a < b ? b : a;

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

    ReplyDelete
  5. 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
  6. 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
  7. 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


  8. 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
  9. This article is interesting, if you want to know more visit our website.

    dadu online
    WA : +62 813 5504 1626


    ReplyDelete
  10. 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
  11. The web site is lovingly serviced and saved as much as date. So it should be, thanks for sharing this with us. 트레이딩벳 먹튀

    ReplyDelete
  12. 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
  13. 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
  14. 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
  15. Incredible articles and awesome design. Your blog entry merits the greater part of the positive input it"s been getting. บาคาร่า

    ReplyDelete






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

    ReplyDelete
  17. 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
  18. Nice post. I really appreciated it. If You Want to Know SUNDULPOKER The Most Trusted IDN Online Poker Site in Indonesia, More Info You Can Read Directly on this site http://supergameindo.com/sundulpoker-situs-idn-poker-online-terpercaya-di-indonesia/

    ReplyDelete
  19. Nice post. I really appreciated it. If You Want to Know How to Register Online Poker on the Official Website Can Get Bonus Directly, More Info You Can Read Directly on this site http://easyletras.com/cara-daftar-poker-online-di-situs-resmi-bisa-langsung-dapat-bonus/

    ReplyDelete
  20. If You Want to Know How to Play Poker for Beginners on IDN Poker Proven Effective, More Info You Can Read Directly on this site http://michael-kors.info/cara-bermain-poker-bagi-pemula-di-idn-poker-terbukti-ampuh/

    ReplyDelete
  21. Great post. if you want to know how to win playing poker with simple strategy you can find and read directly on this site http://strategimenang.xyz/

    ReplyDelete
  22. Amazing post. I will share this to all my friend. Please visit my web if you want to know what trik i used to win playing poker online you can click this site https://forum.telus.com/t5/user/viewprofilepage/user-id/59490

    ReplyDelete
  23. Dalam permainan poker tidak bisa menggunakan strategi yang asal-asalan, untuk itu anda bisa cek link yang saya bagikan untuk mendapatkan strategi jitu yang telah berhasil dibuktikan oleh saya dan beberapa pemain poker senior lainnya. Cek this link https://dewastrategi.exposure.co/

    ReplyDelete
  24. Nice one. If you need some info abou trik to win play poker you can visit on this site https://www.diggerslist.com/dewastrategixyz/about

    ReplyDelete
  25. Situs IDN Poker yang sudah berjalan selama 6 tahun dan tetap eksis, situs tersebut bernama SundulPoker. Informasi lebih lanjut bisa anda temukan di link https://www.intensedebate.com/people/jitustrategy

    ReplyDelete
  26. Dengan hanya membuat 1 User ID saja anda bisa menikmati semua permainan yang tersedia seperti TexasPoker, DominoQQ, BandarCEME, CemeKeliling, CapsaSusun, Omaha dan Super10. Infonya bisa anda lihat di https://express.yudu.com/library/1129460/linkv.net

    Selain bisa dimainkan dengan 1 user ID, sundulpoker juga memberikan banyak keuntungan kepada para pemainnya. Informasi detailnya bisa anda lihat di https://torgi.gov.ru/forum/user/profile/810703.page

    Situs SundulPoker tidak pernah memiliki trackrecord yang jelek/penipuan. Karena situs ini sudah memiliki sertifikat izin resmi perjudian international, bisa anda lihat di http://www.folkd.com/user/linkv.net

    ReplyDelete
  27. Daftar IDN Poker Online Tanpa Syarat Mudah Dapat Bonus Cek info lengkapnya di https://express.yudu.com/library/1129460/linkv.net

    SundulPoker Menyediakan Banyak Hadiah Uang Asli, Langsung saja cek infonya di https://www.pozible.com/profile/johnson-sundul

    ReplyDelete
  28. It is the only safety park community in Korea. Gorilla Toto is the best place to look for safety parks. This is a safety park where you can check the real reviews. 안전놀이터

    ReplyDelete
  29. Thanks for sharing, this one is amazing post.Please visit me at http://learn.smc.edu.ng/members/indpoker-xyz/

    And if you want to know more about poker online https://tawk.to/indpoker

    ReplyDelete
  30. Daftar IDN Poker Online Indonesia 2019 Terpopuler Paling Ramai Dimainkan http://www.authorstream.com/gameuangasli/
    Playernya bisa mencapai ratusan ribu yang aktif setiap harinya, informasi lebih detail bisa anda baca dilink https://marketplace.whmcs.com/user/gameuangasli2526

    ReplyDelete
  31. jika anda ingin tau seputar dunia perjudian kartu poker cek link ini https://regenbox.org/en/forums/users/Tantowi_Sumardi/

    Jika anda seorang pemain poker yang sedang membutuhkan strategy untuk menang main poker cek di link ini https://issuu.com/traveldheworld

    ReplyDelete
  32. Amazing post. Please visit my web if you want to know more about online poker
    https://www.adsoftheworld.com/user/ikanmassuper

    Visit this link if you want to know what benefits that you can get if you play poker in the best IDN Poker site
    https://www.ulule.com/ikanmassuper/#/projects/followed

    ReplyDelete
  33. Playing Poker Can Get Millions of Money in One Night Definitely Sure More Info Check on this Site http://wafironline.com/author/ikanmassuper/

    ReplyDelete
  34. Cara Menang Poker Online Dengan Teknik Dewa Judi Paling Jitu https://www.viki.com/users/sumarditanto123_889/about

    Trik ini hanya bisa digunakan di situs yang bernama SundulPoker https://www.couchsurfing.com/people/winstar-club

    ReplyDelete
  35. Dapatkan Bonus Deposit Terbesar Hanya Di Situs IDN Poker SundulPoker https://mru.org/users/146733

    Dengan Bonus Tersebut Anda Bisa Gunakan Untuk Raih Keuntungan Hingga Jutaan Rupiah https://www.producthunt.com/@tantowi_sumardi

    ReplyDelete
  36. Gunakan Teknik Terbaik Untuk Dapat Menang Di Situs IDN Poker SundulPoker http://impression3d.laposte.fr/en/users/linkv

    Teknik tersebut bisa anda check di Link https://git-dev.dartmouth.edu/linkv

    ReplyDelete
  37. Gorillas are always looking for honest casino site recommendations. Boasts a dubbed casino site, the Casino Gorilla is the best.  바카라사이트

    ReplyDelete
  38. Hi there, I found your blog via Google while searching for such kinda informative post and your post looks very interesting for me. sexy gaming

    ReplyDelete
  39. learn poker with real money hand analysis so you master poker strategy not only theoretically but in practice! 바둑이사이트

    ReplyDelete
  40. They enjoy the simulation offered by these online games and most of the times get their friends involved to take full advantage of the unlimited number of players they can enjoy competing with over the internet. 메이저사이트

    ReplyDelete


  41. 년대 초 처음 나온 스포츠토토는 게임 참가자가 야구,농구,축구,골프,씨름 등의 경기 결과를 예측해 베팅한 뒤 결과에 따라 배당금을 받는 게임입니다. 스포츠경기의 승,무,패를 맞히는 게임(승부식), 경기 득점,실점을 맞히는 게임(점수식), 승·무·패와 득실점을 동시에 맞히는 게임(혼합식) 등으로 구분돼 있다. 우리나라의 유일한 국민체육진흥공단이 발행하는 합법적인 베팅업체는 케이토토 베트맨토토입니다. 우리 나라의 합법적인 베팅업체 케이토토,베트맨토토는 배당률도 낮고 경기수가 적습니다. 결국 회원들은 베트맨토토에서 수익을 내는게 거의 불가능하다고 봅니다. 그래서 사람들은 보다 다양하고 선택권이 넓은 사설토토사이트로 눈을 돌렸습니다. 케이토토,베트맨토토보다 배당, 안전성 등 매력적인 부분이 많았습니다. 하지만 단점은 있었습니다. 먹튀가 존재한다는 점입니다. 반면에 장점도 있었습니다.
    토토사이트

    ReplyDelete
  42. I simply wanted to thank you a lot more for your amazing website you have developed here. It can be full of useful tips for those who are actually interested in this specific subject, primarily this very post. website

    ReplyDelete
  43. Remarkable things you've by and large granted to us. Basically proceed with composed work this kind of posts.The time which was wasted in going for instructive cost now it very well may be used for studies.Thanks 토토사이트

    ReplyDelete
  44. This is a wonderful product, taking into account all the information about it, this type of product that prevents user interest in the site, and you will share more ... good luck.  먹튀사이트

    ReplyDelete
  45. Your post is very helpful to get some effective tips to reduce weight properly. You have shared various nice photos of the same. I would like to thank you for sharing these tips. Surely I will try this at home. Keep updating more simple tips like this. Judi Casino Online Terbaik

    ReplyDelete
  46. Amazing things you've for the most part conferred to us. Essentially proceed with composed work this kind of posts.The time which was wasted in going for instructive cost now it tends to be used for studies.Thanks 꽁머니 3만

    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