Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.
Trending News
Static method help...Comp Sci?
Okay, in this static method we are testig to see which set of values for "pickOne" will result in 3.
I'm guessing that all of these inputs will result in 3, since 3 is returned at the very end of the code.
WHat do you think??
public static int pickOne( int a, int b, int c )
{
if ( a < b && (b < c || a < c) )
return a;
if ( b < c )
return b;
return c;
}
Which of these expressions has the value 3?
pickOne( 2, 2, 3)
pickOne( 3, 3, 3)
pickOne( 3, 4, 4)
2 Answers
- 1 decade agoFavorite Answer
public class thisiscrapifyoucannotrunthis
{
public static int pickOne( int a, int b, int c )
{
if ( a < b && (b < c || a < c) )
return a;
if ( b < c )
return b;
return c;
}
public static void main(String[] args)
{
System.out.println(pickOne( 2, 2, 3));
System.out.println(pickOne( 3, 3, 3));
System.out.println(pickOne( 3, 4, 4));
}
}
the second and third win.
everything under is skipped
1st does not since it returns at the second if statement. Don't quote me on this but I believe once a value is return, everything else is skipped. I do know that's the case between those 2 if statements, if the 1st one is "activated", the 2nd is skipped.
- Anonymous1 decade ago
2,3,3 I think?