Print Array
From CompSciWiki
Back to the Program-A-Day homepage
ProblemWrite a method which will take 3 ints as parameters.
The method should print the elements of the array in order, separated by a comma.
|
...by students | |
---|---|---|
SolutionYou should split this up into three methods which print out the smallest, middle and largest images. public static void printSmallest( int n1, int n2, int n3 ); public static void printMiddle( int n1, int n2, int n3 ); public static void printLargest( int n1, int n2, int n3 ); You will need to use if statements<b> to determine the proper order to print out the numbers. if( n1 <= n2 && n1 <= n3 ) { System.out.print( n1 ); } else if( n2 <= n3 ) { System.out.print( n1 ); } else { System.out.print( n1 ); } | ||
Code |