How do you make an if-then statement return a greater value?
From ggc
I'm working on the Logic problem, blackjack. It says to return the value nearest 21. How can you make it return a value nearest 21? Here's what I have but it doesn't work.
public int blackjack(int a, int b) {
if(a>21 && b>21)
{
return 0;
}
else if(a<=21 && a>b)
{
return a;
}
else if(b<=21 && b>a)
{
return b;
}
else
{
return 0;
}
}
What if both a and b are 21? or if they are both the same?
- This page was last modified on 2 April 2008, at 19:09.
- This page has been accessed 238 times.
- Privacy policy
- About ggc
- Disclaimers
- Powered by MediaWiki!









