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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started