Question: JAVA ILLUMINATED An Active Learning Approach 3 rd Edition. CHAPTER 8 8.10.6 54. Write a method that returns the difference between the largest and smallest

JAVA ILLUMINATED

An Active Learning Approach 3rd Edition.

CHAPTER 8

8.10.6

54. Write a method that returns the difference between the largest and smallest elements in an array of doubles.

public class ArrayDifference { public static void main( String [] args ) { double [] array = { 72.3, 6.7, 12.6, 40.7, 21.8, 49.9 }; System.out.print( "The elements are " ); for ( int i = 0; i < array.length; i++ ) System.out.print( array[i] + " " ); System.out.println( ); System.out.println( "The difference between the largest and " + "smallest elements is " + largestSmallestDifference( array ) ); } // Insert your code below }

58. Write a method that prints all the elements of an array of chars in reverse order.

public class PrintReverseArray { public static void main( String [] args ) { char [] array = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h' }; System.out.print( "The elements are " ); for ( int i = 0; i < array.length; i++ ) System.out.print( array[i] + " " ); System.out.println( ); System.out.print( "The elements in reverse order are " ); arrayReverse( array ); System.out.println( ); } // Insert your code below }

59. Write a method that returns an array composed of all the elements in an array of chars in reverse order.

public class ReturnReverseArray { public static void main( String [] args ) { char [] array = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h' }; System.out.print( "The elements are " ); for ( int i = 0; i < array.length; i++ ) System.out.print( array[i] + " " ); System.out.println( ); char [] arrayReversed = arrayReverse( array ); System.out.print( "The elements in reverse order are " ); for ( int i = 0; i < arrayReversed.length; i++ ) System.out.print( arrayReversed[i] + " " ); System.out.println( ); } // Insert your code below }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!