Question: JAVA ILLUMINATED An Active Learning Approach 3 rd Edition. CHAPTER 8 8.10.6 50. Write a value-returning method that returns the product of all the elements

JAVA ILLUMINATED

An Active Learning Approach 3rd Edition.

CHAPTER 8

8.10.6

50. Write a value-returning method that returns the product of all the elements in an integer array.

public class ArrayProduct { public static void main( String [] args ) { int [] intArray = { 1, 2, 3, 4, 5, 6 }; System.out.print( "The elements are " ); for ( int i = 0; i < intArray.length; i++ ) System.out.print( intArray[i] + " " ); System.out.println( ); System.out.println( "The product of all elements in the array is " + arrayProduct( intArray ) ); } // Insert your code below

51. Write a void method that sets to 0 all the elements of an integer array.

public class ZeroArrayElements { public static void main( String [] args ) { int [] intArray = { 1, 2, 3, 4, 5, 6 }; System.out.print( "The elements are " ); for ( int i = 0; i < intArray.length; i++ ) System.out.print( intArray[i] + " " ); System.out.println( ); System.out.println( "Calling zeroArray method" ); zeroArray( intArray ); System.out.print( "The elements are " ); for ( int i = 0; i < intArray.length; i++ ) System.out.print( intArray[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!