Java > Logic-1 > greenTicket (CodingBat Solution)

Problem:

You have a green lottery ticket, with ints a, b, and c on it. If the numbers are all different from each other, the result is 0. If all of the numbers are the same, the result is 20. If two of the numbers are the same, the result is 10.

greenTicket(1, 2, 3) → 0
greenTicket(2, 2, 2) → 20
greenTicket(1, 1, 2) → 10


Solution:

public int greenTicket(int a, int b, int c) {
  if (a == b && b == c)
    return 20;
  if (a == b || a == c || b == c)
    return 10;
  else;
    return 0;
}


18 comments :

  1. A valuable piece of data for lottery online is the variety of numbers. They ought not be all odd or every considerably number. It ought to be an assemblage of both, or one can pick back to back numbers like 5 and 6 or 20 and 21 and so forth. buying bulk lottery tickets

    ReplyDelete
  2. This article is an appealing wealth of informative data that is interesting and well-written. This is exceptionally instructive substance and composed well for a change. It's pleasant to see that a few individuals still see how to compose a quality post! Currently, Lottery can be considered the right place where one can easily train yourself in their favourite games. It is the only place where one can improve their gambling skills slightly than playing. mơ gãy răng đánh con gì

    ReplyDelete
  3. Wonderful article, thanks for putting this together! This is obviously one great post. Thanks for the valuable information and insights you have so provided here. It's proven that the more lines you play, the higher your win odds become, and the greater chance of a major win success. The other way to win is to consider buying a lottery plan a plan that has been tested and perfected to increase the chance of a major lottery win. 188loto.com

    ReplyDelete
  4. public int greenTicket(int a, int b, int c) {
    return (a == b && b == c)? 20 :
    (a == b || b == c || a == c)? 10 :
    0;
    }

    ReplyDelete
  5. Awesome article, I am a big fan of this website, keep on posting that great content, and I'll be a regular visitor for a long time...looking for the next one....keep it up! cách ghép 3 càng chuẩn tại 188loto

    ReplyDelete
  6. if((a!=b)&&(a!=c)&&(b!=c))
    return 0;
    if((a==b) && (a==c) && (b==c))
    return 20;
    else return 10;

    ReplyDelete
  7. Simply appreciating your work and thinking about how you dealt with this blog so well. It's striking to such an extent that I can't stand to not experience this important data at whatever point I surf the web! 먹튀사이트

    ReplyDelete
  8. An interesting dialogue is price comment. I feel that it is best to write more on this matter, it may not be a taboo topic however usually individuals are not enough to talk on such topics. To the next. Cheers. Health Insurance Subsidy

    ReplyDelete
  9. 대부분 먹튀가 발생하는 과정은 환전 단계입니다. 안전한 메이저놀이터와 안전공원이라면 상관은 없지만, 만약 처음 사이트를 신중히 고르지 않고 먹튀사이트를 고르게 됐다면 결국은 환전 단계에서 많은 금액을 먹이게 될 것입니다. 먹튀검증

    ReplyDelete
  10. 보통 이런 환전이 이상할 거라는 사설 사이트는 어느 정도 알 수 있는 방법은 환전이 느린 사이트입니다. 메이저공원

    ReplyDelete
  11. When your website or blog goes live for the first time, it is exciting. That is until you realize no one but you and your. 우리카지노

    ReplyDelete
  12. This is certainly what is more a fairly superior blog post that many of us without doubt adored measuring. Not likely each and every day which unfortunately utilize the prospects to get yourself a system. securityguardla.com

    ReplyDelete
  13. Thanks for the blog loaded with so many information. Stopping by your blog helped me to get what I was looking for. Plastic Pipe & Fittings

    ReplyDelete
  14. Welcome! I'm Consuelo, a yoga teacher on a mission to bring a sense of balance and freedom into your life through the practice of Vinyasa and Restorative 안전공원...

    ReplyDelete
  15. Top Cbse Schools In Btm. Holistic Development Through Public Speaking, Reading Programs, Schedule A Campus Visit By Submitting An Online Inquiry. Admissions Open For 21-22. Girls School 먹튀.

    ReplyDelete
  16. Certain dissertation web sites over the internet courses currently have evidently unveiled while in the web-site.spells caster

    ReplyDelete
  17. public int redTicket(int a, int b, int c) {
    if (a == 2 && b == 2 && c== 2)
    return 10;
    if (a == b && b == c)
    return 5;
    if(a != b && a != c)
    return 1;
    return 0;
    }

    ReplyDelete
  18. public int greenTicket(int a, int b, int c) {
    if (a != b && b != c && c !=a)
    return 0;
    else if (a == b && b ==c && c ==a)
    return 20;
    else
    return 10;
    }

    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